Christo S. Christov
Christo S. Christov

Reputation: 2309

Read resource information from an assembly at runtime

var asm = Assembly.GetEntryAssembly();
this.Image = Properties.Resources.ResourceManager
                                .GetString(logicalOptions.GetType().Name);

Is there a way to retrieve the ResourceManager for an assembly which is dynamically discovered?

I would like to access the ResourceManager of the asm assembly.

Thanks

Upvotes: 0

Views: 51

Answers (1)

NineBerry
NineBerry

Reputation: 28519

    private ResourceManager GetResourceManager(Assembly assembly)
    {
        // Guess namespace name 
        var namespaceName = Path.GetFileNameWithoutExtension(assembly.CodeBase);
        namespaceName = namespaceName + ".Properties.Resources";

        return new ResourceManager(namespaceName, assembly);
    }

Upvotes: 1

Related Questions