By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

Problem loading embedded resource

P: n/a
Assembly asm = Assembly.GetExecutingAssembly();

me = new Bitmap(asm.GetManifestResourceStream("me.gif"));

I have used this before without any problem, but now I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll

Additional information: 'null' is not a valid value for 'stream'.

I've got the Build Action for me.gif set as Embedded Resource.

Argh!

Why can't it find the file?

Thnx!

Drew
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
100
Hi Drew,
Probably the the full name of the resource is not right. Use ILDasm to see
the actual name of the resource.
Normaly resources are named
<Default Namespace>[.<subdir>].<resource-file name>

where
*Default Namespace* is the one set in the project properties.
*subdir* if any is in the casses where you keep resource files in different
forlders under your project.
*<resource-file name>* is the name of the resource files.

But my suggestion is to use ILDasm to see the name of the resources. You can
find them in MANIFEST node in the main screen

HTH
B\rgds
100
"Drew" <so*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Assembly asm = Assembly.GetExecutingAssembly();

me = new Bitmap(asm.GetManifestResourceStream("me.gif"));

I have used this before without any problem, but now I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll

Additional information: 'null' is not a valid value for 'stream'.

I've got the Build Action for me.gif set as Embedded Resource.

Argh!

Why can't it find the file?

Thnx!

Drew

Nov 15 '05 #2

P: n/a
OK, it looks like I just forgot to include the namespace
when trying to read the embedded resource. :)

Now, I just want to remove the namespace altogether
in Visual Studio, but just removing the namespace from
the code doesn't seem to do the trick.

What else has to be done to remove the namespace?

Drew


"100" <10*@100.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi Drew,
Probably the the full name of the resource is not right. Use ILDasm to see
the actual name of the resource.
Normaly resources are named
<Default Namespace>[.<subdir>].<resource-file name>

where
*Default Namespace* is the one set in the project properties.
*subdir* if any is in the casses where you keep resource files in different forlders under your project.
*<resource-file name>* is the name of the resource files.

But my suggestion is to use ILDasm to see the name of the resources. You can find them in MANIFEST node in the main screen

HTH
B\rgds
100
"Drew" <so*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Assembly asm = Assembly.GetExecutingAssembly();

me = new Bitmap(asm.GetManifestResourceStream("me.gif"));

I have used this before without any problem, but now I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll

Additional information: 'null' is not a valid value for 'stream'.

I've got the Build Action for me.gif set as Embedded Resource.

Argh!

Why can't it find the file?

Thnx!

Drew


Nov 15 '05 #3

P: n/a
100
Hi Drew,
The only way I can thing of is to go in Project | <prj name> Properties |
General and delete the *Default Namespace* and rebuild the project. Anyway,
I don't thing is a good idea because that *Default Namespace* is used by the
IDE when generates classes, forms, etc. If you delete this property you have
to add the namespaces for the latter by hand. Thus, better decorate you
resource names with the namespace when you read the resources. Otherwie
IMHO the pain will be bigger.

B\rgds
100

"Drew" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OK, it looks like I just forgot to include the namespace
when trying to read the embedded resource. :)

Now, I just want to remove the namespace altogether
in Visual Studio, but just removing the namespace from
the code doesn't seem to do the trick.

What else has to be done to remove the namespace?

Drew


"100" <10*@100.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi Drew,
Probably the the full name of the resource is not right. Use ILDasm to see the actual name of the resource.
Normaly resources are named
<Default Namespace>[.<subdir>].<resource-file name>

where
*Default Namespace* is the one set in the project properties.
*subdir* if any is in the casses where you keep resource files in

different
forlders under your project.
*<resource-file name>* is the name of the resource files.

But my suggestion is to use ILDasm to see the name of the resources. You

can
find them in MANIFEST node in the main screen

HTH
B\rgds
100
"Drew" <so*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Assembly asm = Assembly.GetExecutingAssembly();

me = new Bitmap(asm.GetManifestResourceStream("me.gif"));

I have used this before without any problem, but now I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll

Additional information: 'null' is not a valid value for 'stream'.

I've got the Build Action for me.gif set as Embedded Resource.

Argh!

Why can't it find the file?

Thnx!

Drew



Nov 15 '05 #4

P: n/a
This seems to work pretty good:

asm.GetManifestResourceStream(asm.GetName().Name+ ".me.gif")

So, turns out it's not really the namespace it wants but the Assembly Name?

I actually tried making the Default Namespace blank in the project
properties but that didn't help.

Would I have to remove the Assembly name in the project properties to be
able to eliminate the naming decoration?

Drew

"100" <10*@100.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
Hi Drew,
The only way I can thing of is to go in Project | <prj name> Properties |
General and delete the *Default Namespace* and rebuild the project. Anyway, I don't thing is a good idea because that *Default Namespace* is used by the IDE when generates classes, forms, etc. If you delete this property you have to add the namespaces for the latter by hand. Thus, better decorate you
resource names with the namespace when you read the resources. Otherwie
IMHO the pain will be bigger.

B\rgds
100

"Drew" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OK, it looks like I just forgot to include the namespace
when trying to read the embedded resource. :)

Now, I just want to remove the namespace altogether
in Visual Studio, but just removing the namespace from
the code doesn't seem to do the trick.

What else has to be done to remove the namespace?

Drew


"100" <10*@100.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi Drew,
Probably the the full name of the resource is not right. Use ILDasm to see the actual name of the resource.
Normaly resources are named
<Default Namespace>[.<subdir>].<resource-file name>

where
*Default Namespace* is the one set in the project properties.
*subdir* if any is in the casses where you keep resource files in

different
forlders under your project.
*<resource-file name>* is the name of the resource files.

But my suggestion is to use ILDasm to see the name of the resources. You
can
find them in MANIFEST node in the main screen

HTH
B\rgds
100
"Drew" <so*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
> Assembly asm = Assembly.GetExecutingAssembly();
>
> me = new Bitmap(asm.GetManifestResourceStream("me.gif"));
>
> I have used this before without any problem, but now I get:
>
> An unhandled exception of type 'System.ArgumentException' occurred

in > system.drawing.dll
>
> Additional information: 'null' is not a valid value for 'stream'.
>
> I've got the Build Action for me.gif set as Embedded Resource.
>
> Argh!
>
> Why can't it find the file?
>
> Thnx!
>
> Drew
>
>



Nov 15 '05 #5

P: n/a
100
Hi Drew,
I actually tried making the Default Namespace blank in the project
properties but that didn't help. It worked for me. When I removed *Default Assembly* and rebuild the project
the resources didn't have "decorations" anymore.

Would I have to remove the Assembly name in the project properties to be
able to eliminate the naming decoration?
No you can't remove the assembly name because this is the name the compiler
will give to the executable.
The *Default Assembly* is what the IDE uses for resources.

Did you keep your resources in a sub-folder under the the project's main
folder. In this case IDE will add the sub-folder name before the resource
file name. In this case AFAIK you can't do anything but put the resources in
the main folder.
Check the "Build Action" for the resources. It has to be "Embedded Resource"

B\rgds
100
Drew

"100" <10*@100.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
Hi Drew,
The only way I can thing of is to go in Project | <prj name> Properties |
General and delete the *Default Namespace* and rebuild the project.

Anyway,
I don't thing is a good idea because that *Default Namespace* is used by

the
IDE when generates classes, forms, etc. If you delete this property you

have
to add the namespaces for the latter by hand. Thus, better decorate you
resource names with the namespace when you read the resources. Otherwie
IMHO the pain will be bigger.

B\rgds
100

"Drew" <so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OK, it looks like I just forgot to include the namespace
when trying to read the embedded resource. :)

Now, I just want to remove the namespace altogether
in Visual Studio, but just removing the namespace from
the code doesn't seem to do the trick.

What else has to be done to remove the namespace?

Drew


"100" <10*@100.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
> Hi Drew,
> Probably the the full name of the resource is not right. Use ILDasm
to see
> the actual name of the resource.
> Normaly resources are named
> <Default Namespace>[.<subdir>].<resource-file name>
>
> where
> *Default Namespace* is the one set in the project properties.
> *subdir* if any is in the casses where you keep resource files in
different
> forlders under your project.
> *<resource-file name>* is the name of the resource files.
>
> But my suggestion is to use ILDasm to see the name of the resources.

You can
> find them in MANIFEST node in the main screen
>
> HTH
> B\rgds
> 100
> "Drew" <so*****@hotmail.com> wrote in message
> news:O4**************@TK2MSFTNGP09.phx.gbl...
> > Assembly asm = Assembly.GetExecutingAssembly();
> >
> > me = new Bitmap(asm.GetManifestResourceStream("me.gif"));
> >
> > I have used this before without any problem, but now I get:
> >
> > An unhandled exception of type 'System.ArgumentException' occurred in > > system.drawing.dll
> >
> > Additional information: 'null' is not a valid value for 'stream'.
> >
> > I've got the Build Action for me.gif set as Embedded Resource.
> >
> > Argh!
> >
> > Why can't it find the file?
> >
> > Thnx!
> >
> > Drew
> >
> >
>
>



Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.