Could not find any resources appropriate for the specified culture (C# WinForm Images in Resource File)

后端 未结 4 671
野趣味
野趣味 2021-01-13 07:45

I added three images to a file called Resource1.resx. I also added one string just for test purposes. I\'m getting this error on either the GetString or the GetObject(image

4条回答
  •  无人共我
    2021-01-13 08:48

    The 1st argument is wrong. But, there is already a ResourceManager created for you. You can see its code: in the Solution Explorer window open the Properties node, open the Resources.resx node and double-click the Resources.Designer.cs file.

    You'll get its instance with Properties.Resources.ResourceManager. If you added the bitmaps with Project + Properties, Resources tab (strongly recommended), you can just refer to the property by the name you gave it. Like Properties.Resources.circleGreen. Do beware that you get a new image object each time you use the property, you may need to copy it to a variable if you use it more than once.

提交回复
热议问题