I have a C# library (MyApp.ServiceLayer) and I want to access a common resx (/Resources/global.en-GB.resx) file from another library (MyApp.Common). I've added a reference from ServiceLayer to Common.
In the /bin/Debug folder of ServiceLayer I have (amongst others):
Reflector tells me that MyApp.Common.resources.dll has a Resources folder and a resource file: MyApp.Common.Resources.global.en-GB.resources
This code returns "could not load assembly" error.
ResourceManager resource = new ResourceManager("resources.global", Assembly.Load(new AssemblyName("MyApp.Common.resource")));
Why can't I get to it?
The loading by AssemblyName only works if the resource file has been loaded into the current AppDomain.
Use the method LoadFrom() instead of Load() to load the assembly from a file:
ResourceManager resource = new ResourceManager("resources.global", Assembly.LoadFrom(@"C:\full\path\of\the\assembly\MyApp.Common.resources.dll"));