在运行时从程序集中读取资源信息

时间:2016-02-17 11:31:20

标签: c#

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

有没有办法检索动态发现的程序集的ResourceManager

我想访问ResourceManager程序集的asm

由于

1 个答案:

答案 0 :(得分:1)

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

        return new ResourceManager(namespaceName, assembly);
    }