erodewald
erodewald

Reputation: 1825

Load "loose" localized resources at runtime?

I have a web service which supplies me with a generated .resx (XML only) which I then convert to binary a .resources file. I am currently generating an assembly file with that using al.exe. Here are my arguments:

/t:lib /c:{culture} /embed:"{.resource input}" /out:"{.dll output}"

Loading this assembly in via Assembly.LoadFrom(file) works fine, but I believe that my assembly is not properly generated. It has no type, namespace, or methods to invoke and therefor no ResourceManager apparently.

Essentially I am just wondering if it is at all possible to generate, load, and utilize resources that have no class or namespace which my project knows about at compile time. Thanks.

Upvotes: 1

Views: 1714

Answers (1)

Dzienny
Dzienny

Reputation: 3417

Your assembly is a satellite assembly. From MSDN:

By definition, satellite assemblies can only contain resources. They cannot contain any executable code.

If you want to access the resources of this assembly - similar code should work:

ResourceManager rm = new ResourceManager(
    "ResourceTest.Properties.Resources", 
     Assembly.LoadAssembly(file));
MessageBox.Show(rm.GetString("helloWorldString"));

Also, the article from MSDN: Walkthrough: Loading Resources from a Satellite Assembly shows an alternative way of how to load a resource string from a satellite assembly.

Upvotes: 4

Related Questions