Jason
Jason

Reputation: 2197

FileNotFoundException on MyProject.resources

I am trying to add an image to a button (C# Winform, VS2010). I have added the resource by Adding Existing Item in the Resources.resx file. I then assign my image to the button and all appears well. When i run my program i get:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'BmsReplayAnalysis.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. 

in this code:

public static System.Drawing.Bitmap play1 {
    get {
        object obj = ResourceManager.GetObject("play1", resourceCulture); <-- DIES HERE
        return ((System.Drawing.Bitmap)(obj));
        }
    }

Can anyone tell me what i am doing wrong?

Upvotes: 3

Views: 2776

Answers (1)

Grant
Grant

Reputation: 684

When you just give it a name of a file, when you run it, it looks for it in the folder that it is running out of. If you are running in debug mode, it will look for play1 inside the debug folder. if its not there its an error.

Upvotes: 1

Related Questions