C# 无法在代码中加载resx文件

C# 无法在代码中加载resx文件,c#,.net,localization,resx,C#,.net,Localization,Resx,我有一个C库MyApp.ServiceLayer,我想从另一个库MyApp.common访问公共resx/Resources/global.en-GB.resx文件。我已经添加了一个从ServiceLayer到Common的引用 在ServiceLayer的/bin/Debug文件夹中,我有: MyApp.Common.dll en gb/MyApp.Common.resources.dll。 /参考资料/global.en-GB.resx Reflector告诉我MyApp.Common.re

我有一个C库MyApp.ServiceLayer,我想从另一个库MyApp.common访问公共resx/Resources/global.en-GB.resx文件。我已经添加了一个从ServiceLayer到Common的引用

在ServiceLayer的/bin/Debug文件夹中,我有:

MyApp.Common.dll en gb/MyApp.Common.resources.dll。 /参考资料/global.en-GB.resx Reflector告诉我MyApp.Common.resources.dll有一个资源文件夹和一个资源文件:MyApp.Common.resources.global.en-GB.resources

此代码返回无法加载程序集错误

ResourceManager resource = new ResourceManager("resources.global", Assembly.Load(new AssemblyName("MyApp.Common.resource")));

为什么我不能访问它?

仅当资源文件已加载到当前AppDomain中时,按AssemblyName加载才有效

使用LoadFrom而不是Load方法从文件加载程序集:

ResourceManager resource = new ResourceManager("resources.global", Assembly.LoadFrom(@"C:\full\path\of\the\assembly\MyApp.Common.resources.dll"));