Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 在.NETCore1.0中使用resx资源_Asp.net Core_Asp.net Core Mvc - Fatal编程技术网

Asp.net core 在.NETCore1.0中使用resx资源

Asp.net core 在.NETCore1.0中使用resx资源,asp.net-core,asp.net-core-mvc,Asp.net Core,Asp.net Core Mvc,我试图在ASP.NET核心项目中使用资源(.resx)文件。我让它在rc1中使用namedResource工作,但似乎无法在RTM中工作。下面是my project.json的外观: "buildOptions": { "embed": { "include": [ "Resources/resource.resx" ] } } 我是这样访问它的: Resources.ResourceManager.GetString("Field1"); 似乎资源没有被嵌入,因为在调试时什

我试图在ASP.NET核心项目中使用资源(.resx)文件。我让它在rc1中使用namedResource工作,但似乎无法在RTM中工作。下面是my project.json的外观:

"buildOptions": {
  "embed": {
    "include": [ "Resources/resource.resx" ]
  }
}
我是这样访问它的:

Resources.ResourceManager.GetString("Field1");
似乎资源没有被嵌入,因为在调试时什么都没有


非常感谢您的帮助。

有关资源使用中的字符串: 删除嵌入

var x = ResourceFoo.Field1;
对于资源使用中的文件: 包括文件的嵌入(例如:/Folder1/***)
Assembly.getExecutionGassembly().GetManifestResourceStream(“Folder1.Folder2.file.ext”)

找到了答案!这是弗莱克先生解决这个问题的方法。因此,如果我将.resx文件移动到项目的根目录而不是子文件夹中,它将按预期工作。我尝试了各种方法从子文件夹嵌入,但它不再工作。现在我将使用这个解决方法,但我怀疑这是RC2中的一个bug。目前这是一个工具问题。这是否回答了您的问题?