我只想转向基于代码的流畅的映射,但这个问题并不是我的一个NHibernate映射文件所独有的.通过在解决方案资源管理器中右键单击的项目项目的旧属性页就可以了.我希望如果这样一个嵌入式资源的东西依然存在,那么就像project.json那样,我们必须指定这个.
解决方法
我以前的答案不再有效(自RC2起),资源现在被标记为已弃用. (谢谢@Yossarian)
现在正确的方法是使用buildOptions / embed:
... "buildOptions": { "emitEntryPoint": true,"embed": [ "9NLiZmx.png" ] },...
您必须使用project.json中的部分资源,就像这样
{ "compile": "*.cs","resource": [ "mapping.xml" ] }
By default all code files in a directory containing a project.json are included in the project. You can control this with the include/exclude sections of the project.json.
Most sections of the project.json file that deal with files allow glob patterns,which are often called wildcards.
包含/排除属性列表
name default value =============================================== compile compileExclude content **/* contentExclude preprocess compiler/preprocess/**/*.cs preprocessExclude resource compiler/preprocess/resources/**/* resourceExclude shared compiler/shared/**/*.cs sharedExclude publishExclude bin/**;obj/**;**/.*/** exclude
更多信息:http://docs.asp.net/en/latest/dnx/projects.html#including-excluding-files
您可以看到以下示例:
Program.cs中
using System; using System.Reflection; namespace ConsoleApp1 { public class Program { public static void Main(string[] args) { var assemblyName = new AssemblyName("ConsoleApp1"); var resources = string.Join(Environment.NewLine,Assembly.Load(assemblyName).GetManifestResourceNames()); Console.WriteLine("List of Manifest Resource Names"); Console.WriteLine("======================"); Console.WriteLine(resources); } } }
project.json
{ "version": "1.0.0-*","description": "ConsoleApp1 Console Application","authors": [ "Alberto Monteiro" ],"tags": [ "" ],"projectUrl": "","licenseUrl": "","compilationoptions": { "emitEntryPoint": true },"resource": "9NLiZmx.png","dependencies": { },"commands": { "ConsoleApp1": "ConsoleApp1" },"frameworks": { "dnx451": { },"dnxcore50": { "dependencies": { "Microsoft.CSharp": "4.0.1-beta-23516","System.Collections": "4.0.11-beta-23516","System.Console": "4.0.0-beta-23516","System.Linq": "4.0.1-beta-23516","System.Threading": "4.0.11-beta-23516","System.IO": "4.0.11-beta-23516","System.IO.FileSystem": "4.0.1-beta-23225","System.Reflection": "4.1.0-beta-23516" } } } }
产量
List of Manifest Resource Names ====================== ConsoleApp1.9NLiZmx.png
原文地址:https://www.jb51.cc/csharp/93778.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。