473,403 Members | 2,366 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,403 software developers and data experts.

gif as embedded resource

Hi,

I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?

thanks a lot,

Al.
Aug 13 '07 #1
10 4070
On Aug 13, 3:48 pm, "Alain R." <noem...@nospam.comwrote:
I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?
Hard to say:

1) What exactly is happening?
2) Is imgStream null?
3) Have you used ildasm/reflector/anything else to see what manifest
resources are actually present?

Jon

Aug 13 '07 #2
Yes imgStrem is still equal to NULL :-(

Jon Skeet [C# MVP] wrote:
On Aug 13, 3:48 pm, "Alain R." <noem...@nospam.comwrote:
>I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource
-"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?

Hard to say:

1) What exactly is happening?
2) Is imgStream null?
3) Have you used ildasm/reflector/anything else to see what manifest
resources are actually present?

Jon
Aug 13 '07 #3
Hi,

A time ago I posted some code for exactly this, take a look at the archives.

From your code I think that the problem is cause the resourse name shoudl
have the namespace in front. So if the image is named Image1.gif the name fo
the resource is mynamespace.image1.gif

"Alain R." <no*****@nospam.comwrote in message
news:eZ****************@TK2MSFTNGP04.phx.gbl...
Hi,

I have some problem to retrieve an image from my application.
Here is my code :

Stream imgStream = null;
Assembly a = Assembly.GetExecutingAssembly();
imgStream = a.GetManifestResourceStream("SW_Audit.img_ok.gif") ;

PBStep1.Image = new Bitmap(imgStream);

before i embedded this image by doing :
Project-property-resources -add resource-add existing resource ->
"img_ok.gif"

My application namespace is "SW_Audit".

so what have i done wrong ?

thanks a lot,

Al.

Aug 13 '07 #4
Hi,

"Alain R." <no*****@nospam.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
Yes imgStrem is still equal to NULL :-(
See my other post, you need to include the name of teh namespace
Aug 13 '07 #5
On Aug 13, 4:21 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
A time ago I posted some code for exactly this, take a look at the archives.

From your code I think that the problem is cause the resourse name shoudl
have the namespace in front. So if the image is named Image1.gif the name fo
the resource is mynamespace.image1.gif
It looks like he's already got the namespace there though: SW_Audit.

I think it's easiest just to see what's actually there...

Jon

Aug 13 '07 #6
It might be that most of the code in the assembly places types in the
assembly SW_Audit, but I'm guessing that isn't the default namespace for the
project. The OP has to go to the settings of his project, and make sure
that SW_Audit is listed in the "Default namespace" textbox on the
"application" page for the project properties.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
On Aug 13, 4:21 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
>A time ago I posted some code for exactly this, take a look at the
archives.

From your code I think that the problem is cause the resourse name shoudl
have the namespace in front. So if the image is named Image1.gif the name
fo
the resource is mynamespace.image1.gif

It looks like he's already got the namespace there though: SW_Audit.

I think it's easiest just to see what's actually there...

Jon

Aug 13 '07 #7
So for your information, SW_Audit is the real default namespace of my
project (application tab of project-property).

So where is the problem ?

A.
Nicholas Paldino [.NET/C# MVP] wrote:
It might be that most of the code in the assembly places types in the
assembly SW_Audit, but I'm guessing that isn't the default namespace for the
project. The OP has to go to the settings of his project, and make sure
that SW_Audit is listed in the "Default namespace" textbox on the
"application" page for the project properties.
Aug 13 '07 #8
Alain,

I just realized that you are adding a resource through a resource file,
not embedding a resource. If you were embedding a resource, then the code
you are using would work. However, you have to ad "img_ok.gif" as an item
to your project, and change the build action to "Embedded Resource".

When you go to the project and add a resource, it will create a
resources file that is added to your project. If you are in Visual Studio
2005, you should also see a new .cs file which contains strongly typed
wrappers for the items in your resource file.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alain R." <no*****@nospam.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
So for your information, SW_Audit is the real default namespace of my
project (application tab of project-property).

So where is the problem ?

A.
Nicholas Paldino [.NET/C# MVP] wrote:
> It might be that most of the code in the assembly places types in the
assembly SW_Audit, but I'm guessing that isn't the default namespace for
the project. The OP has to go to the settings of his project, and make
sure that SW_Audit is listed in the "Default namespace" textbox on the
"application" page for the project properties.

Aug 13 '07 #9
Hi,
"Alain R." <no*****@nospam.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
So for your information, SW_Audit is the real default namespace of my
project (application tab of project-property).

So where is the problem ?

Get a list of all the resources you have using GetManifestResourceNames
Aug 13 '07 #10
In fact, i deleted my former picture from added files, clean the
project, add it again, remove all possible other resources from
Project->property.

Rebuild everything, and the code which was not working till now, works
perfectly now :-(((

so i must have done something wrong before and let the VC# in not
stable/standard way.

Al.

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
"Alain R." <no*****@nospam.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
>So for your information, SW_Audit is the real default namespace of my
project (application tab of project-property).

So where is the problem ?


Get a list of all the resources you have using GetManifestResourceNames

Aug 13 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: james | last post by:
What class / method should I be using to get the full path to an embedded resource ? In my case I have an .xml file that my app uses, it is set as embedded resource, and I have a control that...
5
by: Drew | last post by:
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...
1
by: n! | last post by:
I have an irritating problem with VS.NET2003, C#. I wrote some code that would build my application menu from an XML resource file. Purely to make it easy for me to edit, so I've added this file as...
2
by: Kyle Kaitan | last post by:
I have an assembly (AppResources.dll) which contains a number of embedded resource files. Most of these are key/value pairs of relevant strings; a few are images and sounds; some more are XML...
0
by: ATS | last post by:
HOWTO Make a UserControl deploy an embedded resource. Please help, I need to embed an EXE into a C# UserControl that is run from script in an HTML web page as such: <html> <object...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
4
by: Jason Pettys | last post by:
In an ASP.NET project I am setting the content type of my .ascx and ..aspx files to Embedded Resource for a separate reason. When I do this they get embedded as "RootNamespace.Filename" but I...
3
by: raghu sunkara | last post by:
Hi, How Can i Change or Modify Embedded String Resource In An Assembly. I Need To Modify Embedded String Resource In An Assembly. Please Help Me. Thanks Raghu.
2
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the...
2
by: steve | last post by:
I have the following routine for retrieving error message strigs from a resource file which is embedded in the project. But when it is called I get the error messsage "Could not find any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.