我将三个图像添加到名为 Resource1.resx 的文件中。我还添加了一个字符串只是为了测试目的。我在 GetString 或 GetObject(image-name) 上收到此错误。
{"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 \"TFBIC.RCT.Monitor\" at compile time, or that all the satellite assemblies required are loadable and fully signed."}
// get initial images
ResourceManager rm = new ResourceManager(
"Resource1",System.Reflection.Assembly.GetExecutingAssembly());
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
string strTest = rm.GetString("String1"); // just testing
Bitmap bmCircleGreen = (Bitmap)rm.GetObject("circleGreen");
Bitmap bmCircleYellow = (Bitmap)rm.GetObject("circleYellow");
Bitmap bmCircleRed = (Bitmap)rm.GetObject("circleRed");
我的表单是我项目中的第一个类(我已经看到那个错误)。
我为我的项目分配了一个强键,但没有用。
不确定还能尝试什么。
最佳答案
您是否记得在引用资源时包含默认命名空间/文件夹?
ResourceManager rm = new ResourceManager("DefaultNamespace.Folder.ResourceName");
如果您不确定名称是否正确,请在 Reflector 中加载程序集并向下浏览以查看它是什么。
关于c# - 找不到适合指定区域性的任何资源(资源文件中的 C# WinForm 图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1923953/