gpt4 book ai didi

asp.net-core - 在 .NET Core 1.0 中使用 resx 资源

转载 作者:行者123 更新时间:2023-12-04 02:29:08 24 4
gpt4 key购买 nike

我正在尝试在 ASP.NET Core 项目中使用资源 (.resx) 文件。我让它在 rc1 中使用 namedResource 工作,但似乎无法在 RTM 中工作。这是我的 project.json 的样子:

"buildOptions": {
"embed": {
"include": [ "Resources/resource.resx" ]
}
}

我是这样访问它的:
Resources.ResourceManager.GetString("Field1");

似乎资源没有被嵌入,因为我调试时没有任何东西。

任何帮助将非常感激。

最佳答案

对于资源使用中的字符串:
删除嵌入。

var x = ResourceFoo.Field1;

对于资源使用中的文件:
包含嵌入文件(例如:/Folder1/**/*)
Assembly.GetExecutingAssembly().GetManifestResourceStream("Folder1.Folder2.file.ext");

关于asp.net-core - 在 .NET Core 1.0 中使用 resx 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38193702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com