tags:

views:

388

answers:

2

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-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");

My form is the first class in my project (I've already seen that error).

I assigned a strong-key to my project to no avail.

Not sure what else to try.

Thanks,

Neal Walters

+1  A: 

Have you remembered to include the default namespace/folder when you reference the resource?

ResourceManager rm = new ResourceManager("DefaultNamespace.Folder.ResourceName");

If you are unsure of the correct name, load the assembly in Reflector and browse down to see what it is.

Mikael Svenson
It wasn't a concept of "remembering" but "knowing" <grin>. I never saw the namespace on any of the examples I had found.
NealWalters
You should also be able to get it strongly typed like nobugz mentions in a static manner: FolderName.ResourceFileName.YourResourceName
Mikael Svenson
+1  A: 

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.

Hans Passant
I found this: internal static global::System.Resources.ResourceManager ResourceManager. Is that what you were talking about. Not sure how to use it. Since it's static, I tried "ResourceManager.getObject"... but that didn't work.
NealWalters
Sorry, I read your post again, it worked: Bitmap bmCircleGreen = (Bitmap) Properties.Resources.ResourceManager.GetObject("circleGreen");
NealWalters