473,695 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem loading embedded resource

Assembly asm = Assembly.GetExe cutingAssembly( );

me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));

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

An unhandled exception of type 'System.Argumen tException' 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 8225
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*****@hotmai l.com> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Assembly asm = Assembly.GetExe cutingAssembly( );

me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));

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

An unhandled exception of type 'System.Argumen tException' 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******** ******@TK2MSFTN GP11.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*****@hotmai l.com> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Assembly asm = Assembly.GetExe cutingAssembly( );

me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));

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

An unhandled exception of type 'System.Argumen tException' 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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******** ******@TK2MSFTN GP11.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*****@hotmai l.com> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Assembly asm = Assembly.GetExe cutingAssembly( );

me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));

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

An unhandled exception of type 'System.Argumen tException' 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.GetManifest ResourceStream( asm.GetName().N ame+ ".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******** ******@TK2MSFTN GP12.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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******** ******@TK2MSFTN GP11.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*****@hotmai l.com> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
> Assembly asm = Assembly.GetExe cutingAssembly( );
>
> me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));
>
> I have used this before without any problem, but now I get:
>
> An unhandled exception of type 'System.Argumen tException' 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 "decoration s" 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******** ******@TK2MSFTN GP12.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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******** ******@TK2MSFTN GP11.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*****@hotmai l.com> wrote in message
> news:O4******** ******@TK2MSFTN GP09.phx.gbl...
> > Assembly asm = Assembly.GetExe cutingAssembly( );
> >
> > me = new Bitmap(asm.GetM anifestResource Stream("me.gif" ));
> >
> > I have used this before without any problem, but now I get:
> >
> > An unhandled exception of type 'System.Argumen tException' 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
2018
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 add the icons dynamically at runtime. How can you add the icons at runtime without corrupting the image?
7
1754
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 SDK sub-directory, as instructed by the MSDN. Step 2: I used the 'reseditor' to create a file named "MyResources.resources" that contains only some string resources. Step 3: I added this resource file to my existing test assembly (does not do
7
19232
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 outputing all Resources names to a simple textfile. Here nothing is output. Here my code (a little messy after about 3 hours of debugging): // Use the LoadXml method to load the XslTransform
4
2139
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 test=res.GetString("TestString");
8
6546
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> <head> <style> @font-face {
5
14880
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 = this.GetType().Assembly.GetManifestResourceStream("DKPCalc.doc.rtf"); if (stream != null) { StreamReader sr = new StreamReader(stream); richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText);
0
2315
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 application, eg: In the directory the application is installed to: \application.exe \plugins\plugin1.dll
8
12073
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 but I'd like to be able to load a file specified in a .resx resource. I've added my .xaml file to the .resx and can load it in using ResourceManager::GetObject(). The object returned is a System::Array^ which contains System::Byte objects. The...
0
1617
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 resource files for spanish and english strings. The problem is that when I compile the project in the old VS 2005 the neutral-culture resource that is inside the project IS embedded into the final EXE, but with the new VS 2008 THIS FILE IS NOT...
0
8630
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8568
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8845
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8825
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6491
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5839
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4340
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.