Eugene Gluhotorenko
Eugene Gluhotorenko

Reputation: 3164

using .NET resources without building

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 ?

Upvotes: 10

Views: 6858

Answers (2)

sra
sra

Reputation: 23983

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.

Upvotes: 4

mdm
mdm

Reputation: 12630

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.

Upvotes: 5

Related Questions