Click to See Complete Forum and Search --> : Strange Exception???


on1ami
June 3rd, 2002, 07:51 AM
Hello all,

Suddenly I got this strange exception running my code:
---Begin Quote---
An unhandled exception of type
'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the
specified culture (or the neutral culture) in the given assembly. Make sure
"Hoofdmenu.resources" was correctly embedded or linked into assembly
"LogisticRental".
baseName: Hoofdmenu locationInfo: LogisticRental.Hoofdmenu resource file
name: Hoofdmenu.resources assembly: LogisticRental, Version=1.0.884.23456,
Culture=neutral, PublicKeyToken=null
---End Quote---

The error comes from the moment I'm loading an Icon or an Imagelist:
on -> this.imageListButtons.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListButt
ons.ImageStream")));

or on -> this.Icon =
((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

I have already regenerated the resx file but the problem was still there

If I don't use icons there is no problem.

Someone knows what's happening????



Greetings,

Jean Paul

on1ami
June 3rd, 2002, 09:30 AM
Just for info, Greg sended me the solution

Tnx.

Jean Paul, try loading your assembly into ILDASM and making sure you see a
reference to your resource which is named as you are calling it. My guess
is that you have multiple classes declared in your namespace and that your
Form class references one of these other classes for your resource. Try
moving the declaration for your Form class to the top of your cs file.

The reason this happens has to do with how your resources are named in the
generated IL. If you look through your IL using ILDASM you'll probably see
that the resource's actual name is different from the one that the IL is
using to reference it.

--
Greg
http://www.claritycon.com/

"Jean Paul @ opelwilly" <jean.paul@opelwilly.com> wrote in message
news:adfm5p$195be$1@sinclair.be.wanadoo.com...
> Hello all,
>
> Suddenly I got this strange exception running my code:
> ---Begin Quote---
> An unhandled exception of type
> 'System.Resources.MissingManifestResourceException' occurred in
mscorlib.dll
>
> Additional information: Could not find any resources appropriate for the
> specified culture (or the neutral culture) in the given assembly. Make
sure
> "Hoofdmenu.resources" was correctly embedded or linked into assembly
> "LogisticRental".
> baseName: Hoofdmenu locationInfo: LogisticRental.Hoofdmenu resource file
> name: Hoofdmenu.resources assembly: LogisticRental,
Version=1.0.884.23456,
> Culture=neutral, PublicKeyToken=null
> ---End Quote---
>
> The error comes from the moment I'm loading an Icon or an Imagelist:
> on -> this.imageListButtons.ImageStream =
>
((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListButt
> ons.ImageStream")));
>
> or on -> this.Icon =
> ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
>
> I have already regenerated the resx file but the problem was still there
>
> If I don't use icons there is no problem.
>
> Someone knows what's happening????
>
>
>
> Greetings,
>
> Jean Paul
>
>
>
>
>

V. Lorenzo
June 4th, 2002, 07:36 AM
Hi:

That happened to me some time ago. Take a look to your source file. If you have a class declaration in the same file that declares the form, and before the form declaration, this runtime error will raise. The resources will be in the assembly, but associated to other class, the first declared in the source file.

To solve it just need to move all the structure, classes and enum declarations into a separate file or place them at the end of the file, but never before the form declaration.

VictorL

on1ami
June 4th, 2002, 08:07 AM
Indeed, there where two class declarations before the form but the strange thing is that they where there for quite a time. The only differece was that I have moved two enum declarations who where before all class declarations.
Now I moved the classes to the back and everything works fine again. :confused:

Tnx for reply
Jean Paul

Eco
August 25th, 2004, 04:35 AM
Sorry for digging out this old thread, but i have exactly the same problem here (Visual Studio .NET 2003).

I have a form with an imagelist and an internal enum declared before the form class is declared (in the same code section). When i moved the enum declaration to another form, the exception does not occure anymore. The strange thing is, that the constallation worked for a while before.

It seems to be a language bug in my eyes.

Greetings,
Eco