Link to home
Create AccountLog in
Avatar of WinterMuteUK
WinterMuteUKFlag for United Kingdom of Great Britain and Northern Ireland

asked on

MissingManifestResourceException suddenly appearing when converting from .Net 1.1 to .Net 2.0

Hi there,

This problem manifests (ha ha) itself at the following line in all my WinForms projects in my solution:

public void InitializeComponent()
{
...
 ...yadda yadda...

    this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); //Exception!!

 ...yadda yadda...
...
}

Now, this code worked absolutely fine in VS2003, .Net 1.1, no troubles, but I've just recently converted to .Net 2.0 and have now started getting this exception.
I don't have a resource file, I just set the Icon for the project to be 'x.ico'.

For the moment, by commenting out the offending line I can get the system to start, but I want my icons back, how and why?

Wint.

Ps. So you don't suggest here are the solutions I've tried:
 * Ensuring namespace and default namespace are the same,
 * Removing and readding the Icon,
 * I don't have any classes/enums/structs etc defined *above* my Form class,
Avatar of WinterMuteUK
WinterMuteUK
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Update to those who are watching/listening in...

I've found the problem appears to be lying with the .resx files for each of the forms, when I pull down the files from source control the files are 'greyed out' i.e. in the project I will see:

  [-] FrmMyForm.cs
       |- FrmMyForm.resx

with the resx icon being a white square.

If I right click on the resx file and 'Include in project' the icon changes to a 'text document with an arrow coming in from the top left corner' as it should do.

Good news: On compiling *this* version and running it, it all works! Huzzah!
Bad news: Well, more of a question, why isn't the resx file being automatically associated as part of the project, it always used to be (in VS2003)?

Cheers

Wint.

Well no joy so i'll close this question.

Just to clarify on initially getting the solution from the source control I could see nothing but the 'FrmMyForm.cs' file (no resx file blank or not), and had to open my Source client and get the latest version. This put all the resx files in the right place, and upon restarting Visual Studio I got to the point I was in up above.

Hopefully the answer will be of use to some people.

cheers

Wint.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer