Reputation: 13231
Here's my scenario:
I have a .Net (3.5) DLL being referenced by an ASP.Net web application.
One of the classes in the DLL has a .resx file containing an error message string that ultimately gets shown by the calling .aspx page.
The DLL makes use of multiple namespaces, I've set the .resx file to the same namespace as the class that calls it, and the .resx file has the same folder location and filename as the class that uses is, postfixed with 'Resources': i.e.
Class: ClassName.cs
.resx: ClassNameResources.resx
It reads the .resx string (which is compiled in the DLL as an embedded resource) without issue.
The problem I'm having is trying to replace the error message string in the deployed web application - how do I actually do it?
Can you point me at a guide? - the best I've found so far is this one, which says use regen.exe
and al.exe
, but the resulting .resources
file doesn't get used because the error message doesn't change. At this stage I'm not trying to localize for any culture, I'm trying to modify the strings returned for the default culture.
Thanks for any suggestions you can make :o)
Upvotes: 1
Views: 4616
Reputation: 56727
As Lasse V. Karlsen said above, resources files are not the right thing to use for what you want. Basically, the byte code for the class and the resources are compiled into an assembly, which is a single unit in the end.
C# allows you to easily use the resources contained within the resource file through Properties.Resources.... So far so good.
If you were localizing your application, you'd get another Assembly (DLL) which contains the localized resources. The internal mechanisms use that DLL to retrieve the resource data instead of your standard assembly.
The fact that resources are actually stored within the assembly (use Reflector to see what I mean) makes it impossible to just put another resources file into the same folder for the new resources to be used.
Resource files are not like configuration files, which are copied to the deployment folder (or to another location) and then loaded as external files.
If you want to replace resources on the fly as you described, you'd have to use your own resource loading mechanism. I'm pretty sure that you can not use the built-in resource mechanisms for that.
Upvotes: 3