473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Problem loading embedded resource

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
5 8167
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carl Scarlett | last post by:
When I display icons in controls from an imagelist, the icons are "corrupted" if they are added from a resource (or a file) but are fine if I add them using the designer at design time. I need to...
7
by: Ken Allen | last post by:
OK, for a number of reasons I have needed to begin experimenting with resources sooner than I had planned (I had avoided it for now). Step 1: I built the 'reseditor' application that is in the...
7
by: Christofer Dutz | last post by:
Hi, I am trying to read a XML-File which I marked as embedded resource from within the code of my DLL. Unfortunately it doesn't work. On my search for the error I inserted some code for...
4
by: Phil Da Lick! | last post by:
Hello, Got strings.resx included in my assmebly as the default language neutral collection. ResourceManager res=new ResourceManager("strings", Assembly.GetExecutingAssembly()); string...
8
by: traditore | last post by:
Hello. I'm trying to load fonts in a web page using "style" tag. The TTF files are in other page whose URL is, for example, "http://myURL/fonts". The HTML code is something like: <html>...
5
by: Ryan Ramsey | last post by:
I currently have an RTF file added to my project as an embedded resource. I am then using the following code to read it into a richtextbox: Stream stream =...
0
by: npthomson | last post by:
Hi all, This could get a bit complicated but I'll try to be as clear as possible. I've written an application that discovers plugins at runtime using reflection from a subdirectory of the...
8
by: John Dunn | last post by:
Since currently we aren't allowed to have compiled XAML files embedded in C++ apps I'm using Markup::XamlReader::Load to dynamically load XAML files. This works perfectly fine with external files...
0
by: Alejandro Gaio | last post by:
Hello All, I have a problem that appeared with the NEW VERSION of the vb.net compiler (VS 2008). To resume things, I have a project (call it "DocumentAdministrator") with several forms, and two...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.