如何为WinForm应用程序创建全局资源文件?

时间:2011-12-06 09:10:04

标签: c# winforms

我需要为不同的项目使用相同的资源文件。

我的资源文件名称为Resource1.resx 我使用resgen创建了一个.resources扩展文件,并使用al.exe生成了一个.resources.dll

但是当我尝试在我的项目中使用该文件时,我收到一个错误,我的代码与此类似:

ResourceManager resmgr = new ResourceManager("Resource1",
                              Assembly.GetExecutingAssembly());
string msg = resmgr.GetString("name");
MessageBox.Show(msg);

错误信息是这样的:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Resource1.resources" was correctly embedded or linked into assembly "WinTest" at compile time, or that all the satellite assemblies required are loadable and fully signed.

如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

您正在从执行程序集加载资源,但正如您所提到的,您已在单独的程序集中定义了资源。

您应该将它指向资源dll,而不是执行程序集。