Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using .NET resources without building

Tags:

c#

.net

resources

I have application with .resx file. Resx file is simple XML, but after buliding resources save to assembly. So to changing resources i need rebuild my resource assemblies. Is there any way to use resources direct from resx file ?

like image 782
Eugene Gluhotorenko Avatar asked May 25 '11 15:05

Eugene Gluhotorenko


2 Answers

If you are using the ResourceManager class to access your resources, you can use the resgen to compile your .resx file to a .resources file. You can then create a new instance of the ResourceManager class using ResourceManager.CreateFileBasedResourceManager instead of new ResourceManager(...). This allows you to specify a resource file name and a directory to search within.

For an example, take a look at approach B in this tutorial.

like image 90
mdm Avatar answered Oct 11 '22 17:10

mdm


As mdm mentioned but not explicit wrote No you can't do that without compilation or without a ResourceManager.CreateFileBasedResourceManager.

The Resource has a XML structure in the .resx part but this parts just shows the compiler where to find the files which should be included and it only exists in your project and not after the build.

A Resource file is defined as a embedded resource, means it is nested into a assembly. Any change will result in a need for a new compilation.

like image 4
sra Avatar answered Oct 11 '22 16:10

sra