MissingManifestResourceException: Getting globalised values in cod

M

Marc Woolfson

This has been driving me insane since the start of the month.

I am attempting to retrieve globalised values from resource files within a
C# ASP.NET web application in VS 2008 targeting .NET 3.5. I have added two
files to the App_GlobalResources directory:

* WebUI.resx
* WebUI.en-US.resx

both of which have corresponding .designer.cs files generated by the
GlobalResourceProxyGenerator tool. They both have a string entry called
MyString and 'Embedded Resource' has been set for their build action.

The default namespace and assembly name for the application is MyApp.WebUI,
but the .designer.cs files seem to ignore this and uses the namespace
Resources instead.

In the standard ASPX page, all is well when attempting to retrieve values
from the resource files but I am struggling to retrieve the same values
explicitly from code using the following:

ResourceManager rm = new
ResourceManager(typeof(Resources.WebUI).ToString(),
Assembly.GetExecutingAssembly());
string myLocalisedString = rm.GetString(Resources.WebUI.MyString);

I am receiving the following error on line 2:

Could not find any resources appropriate for the specified culture or the
neutral culture. Make sure "Resources.WebUI.resources" was correctly embedded
or linked into assembly "MyApp.WebUI" at compile time, or that all the
satellite assemblies required are loadable and fully signed.

Using my favourite search engine to find a solution resulted in many
suggestions, but I cannot manage to get any of them to resolve the issue.
These include:

* Renaming the resource files to match the default namespace (which
interestingly changes the namespace of the .designer.cs files to
Resources.Namespace rather then Namespace.Resources)
* Removing and re-adding the resource files (oh, the joys of TFS source
control)
* Using the full namespace to the resources in the ResourceManager
constructor (i.e. MyApp.WebUI.WebUI)
* ...many others along the same lines as the above

Typically, the relevant MSDN pages/examples aren't very helpful either.

In my bin directory, I have the following (relevant) files:

* bin/MyApp.WebUI.dll
* bin/MyApp.WebUI.pdb
* bin/en-US/MyApp.WebUI.resources.dll

When I open the bin/MyApp.WebUI.dll file in ildasm.exe I can see Resources >
Resources.WebUI > MyString etc. When I open
bin/en-US/MyApp.WebUI.resources.dll I can't see any entries which is because
the .designer.cs file seems to be empty [I have only just noticed this while
preparing this essay - is this a bug with .culture.resx files?].

Please can someone suggest what else I can try to attempt to resolve this
issue? I believe at least one of the items above is a bug in VS 2008, but am
sure there must be something else basic that I am doing wrong here.

Thanks in advance!

Marc
 
M

Marc Woolfson

Another forum helped me resolve this issue. The following code seems to work
fine:

ResourceManager rm = new
ResourceManager("MyApp.WebUI.App_GlobalResources.WebUI",
Assembly.GetExecutingAssembly());
string myLocalisedString = rm.GetString("MyString");


Marc Woolfson said:
This has been driving me insane since the start of the month.

I am attempting to retrieve globalised values from resource files within a
C# ASP.NET web application in VS 2008 targeting .NET 3.5. I have added two
files to the App_GlobalResources directory:

* WebUI.resx
* WebUI.en-US.resx

both of which have corresponding .designer.cs files generated by the
GlobalResourceProxyGenerator tool. They both have a string entry called
MyString and 'Embedded Resource' has been set for their build action.

The default namespace and assembly name for the application is MyApp.WebUI,
but the .designer.cs files seem to ignore this and uses the namespace
Resources instead.

In the standard ASPX page, all is well when attempting to retrieve values
from the resource files but I am struggling to retrieve the same values
explicitly from code using the following:

ResourceManager rm = new
ResourceManager(typeof(Resources.WebUI).ToString(),
Assembly.GetExecutingAssembly());
string myLocalisedString = rm.GetString(Resources.WebUI.MyString);

I am receiving the following error on line 2:

Could not find any resources appropriate for the specified culture or the
neutral culture. Make sure "Resources.WebUI.resources" was correctly embedded
or linked into assembly "MyApp.WebUI" at compile time, or that all the
satellite assemblies required are loadable and fully signed.

Using my favourite search engine to find a solution resulted in many
suggestions, but I cannot manage to get any of them to resolve the issue.
These include:

* Renaming the resource files to match the default namespace (which
interestingly changes the namespace of the .designer.cs files to
Resources.Namespace rather then Namespace.Resources)
* Removing and re-adding the resource files (oh, the joys of TFS source
control)
* Using the full namespace to the resources in the ResourceManager
constructor (i.e. MyApp.WebUI.WebUI)
* ...many others along the same lines as the above

Typically, the relevant MSDN pages/examples aren't very helpful either.

In my bin directory, I have the following (relevant) files:

* bin/MyApp.WebUI.dll
* bin/MyApp.WebUI.pdb
* bin/en-US/MyApp.WebUI.resources.dll

When I open the bin/MyApp.WebUI.dll file in ildasm.exe I can see Resources >
Resources.WebUI > MyString etc. When I open
bin/en-US/MyApp.WebUI.resources.dll I can't see any entries which is because
the .designer.cs file seems to be empty [I have only just noticed this while
preparing this essay - is this a bug with .culture.resx files?].

Please can someone suggest what else I can try to attempt to resolve this
issue? I believe at least one of the items above is a bug in VS 2008, but am
sure there must be something else basic that I am doing wrong here.

Thanks in advance!

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top