'Using resx resources in .NET Core 1.0
I am attempting to use a resource(.resx) file in an ASP.NET Core project. I had it working in rc1 using a namedResource, but can't seem to get it working in RTM. Here is what my project.json looks like:
"buildOptions": {
"embed": {
"include": [ "Resources/resource.resx" ]
}
}
And I'm accessing it like this:
Resources.ResourceManager.GetString("Field1");
It seems the resources are not getting embedded as There is nothing there when I debug.
Any help would be much appreciated.
Solution 1:[1]
For string in resource use: Remove embed.
var x = ResourceFoo.Field1;
For file in resource use: Include embed for file (ex.: /Folder1/**/*) Assembly.GetExecutingAssembly().GetManifestResourceStream("Folder1.Folder2.file.ext");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Marco Antonio Contarski |