.net Resource DLL with multiple resx files

I need to know the way to properly access strings and images from a resource DLL that has multiple resource files (.resx).

I have a very large project that I am working on and is composed of several winforms each with multiple panels. I am trying to tidy things up a bit by making each form has its own res file and limit the application to one resource DLL instead of multiple resource DLLs.

The problem is when I try and add a new resource file to my resource DLL and try to access a string, for example, that is being saved in the newly created resx file. ResourceManager return a null string.

Here is how I am creating my ResourceManager object and getting the string

static public string GetResourceString(string sStringName)
{     
System.Reflection.Assembly myDllAssembly = System.Reflection.Assembly.LoadFile(ResPath);
     string[] allResourcesinDLL = myDllAssembly.GetManifestResourceNames();
     ResourceManager ResInstance = new ResourceManager(allResourcesinDLL[0].Replace(".resources", string.Empty), myDllAssembly);

 return  ResInstance.GetString(sStringName);
}

Where ResPath is the path to my resource DLL and sStringName is the resource/string title.

I Am not sure if there is a way to specify the resx file to read from or if it should be handled in some other way. Please bear in mind that my application is compiled using the .net 2.0 framework so I am kinda limited to the APIs that I am able to use.

链接地址: http://www.djcxy.com/p/66642.html

上一篇: 如何确保在Visual Studio中完全覆盖本地化资源文件?

下一篇: .net资源DLL与多个resx文件