vendredi 3 juin 2016

How to access default resource from other assembly

I have default resource file (*.resx) compiled in other assembly (just as default Properties.Resources), this assembly referenced by Assembly object. How can I access specific resource object inside it?

I tried:

public static class Resource
{
    public static T Get<T>(Assembly assembly, string name)
    {
        ResourceManager manager = new ResourceManager(assembly.GetName().Name + ".Properties.Resources", assembly);
        return (T)manager.GetObject(name);
    }
}

This throws MissingManifestResourceException and debugger shows that through manager is initialized as ResourceManager instance, the manager.ResourceSet is empty.





Aucun commentaire:

Enregistrer un commentaire