Arno
Arno

Reputation: 11

Use ComponentResourceManager with an assembly dynamically loaded

I created a class to manage resources dynamically derived from ComponentResourceManager:

public class MyResourceManager : ComponentResourceManager
{
    public MyResourceManager(Type _t, Langue _lang) : base(_t)
    {
        if (_lang == Langue.French)
        {
            MainAssembly = Assembly.LoadFile("c:/myCustomFolder/french.dll");
        }
        else
        {
            MainAssembly = Assembly.LoadFile("c:/myCustomFolder/english.dll");
        }
    }
}

When i try to apply the resources to my controls, an exception is raised

public static void UpdateLanguage(Control c, Langue _lang)
{
    MyResourceManager language = new MyResourceManager(c.GetType(), _lang);
    language.ApplyResources(c, c.Name);
}

Exception raised: (when ApplyResources is called)

An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

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

Do you have an idea ?

Upvotes: 0

Views: 945

Answers (1)

likewer
likewer

Reputation: 216

The most common reason for this is that you have changed the namespace name after a Resourse file has been created or that the Build Action of the resource file is not set to Embedded Resource.

Upvotes: 0

Related Questions