473,804 Members | 2,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedded images?

I'm trying to use an embedded image(bitmap) using the following code:

imgDrag = New
System.Drawing. Bitmap(GetType( QueryResultGrid ).Assembly.GetM anifestResource S
tream("Comp.Tec h.QueryResultGr id.ResultsGridD rag.bmp"))

Where QueryResultGrid is the class thats going to use the image,
Comp.Tech.Query ResultGrid is the assembly name and ResultsGridDrag .bmp is
the file name of the embedded resource. However, on runing this line 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'.

Any ideas why? I think that maybe I should be using something other than
"Comp.Tech.Quer yResultGrid.Res ultsGridDrag.bm p"?

--

Cheers,

elziko
Nov 20 '05 #1
2 1372
Hi,

Here is an example. I added the water lilies.jpg to my app get its
build action to embedded resource.
Dim bm As Bitmap

Dim myAsm As System.Reflecti on.Assembly =
System.Reflecti on.Assembly.Get ExecutingAssemb ly()

bm = New Bitmap(myAsm.Ge tManifestResour ceStream(Me.Get Type, "Water
lilies.jpg"))

Ken

---------------

"elziko" <el****@NOTSPAM MINGyahoo.co.uk > wrote in message
news:40******** *************** @news.easynet.c o.uk...
I'm trying to use an embedded image(bitmap) using the following code:

imgDrag = New
System.Drawing. Bitmap(GetType( QueryResultGrid ).Assembly.GetM anifestResource S
tream("Comp.Tec h.QueryResultGr id.ResultsGridD rag.bmp"))

Where QueryResultGrid is the class thats going to use the image,
Comp.Tech.Query ResultGrid is the assembly name and ResultsGridDrag .bmp is
the file name of the embedded resource. However, on runing this line 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'.

Any ideas why? I think that maybe I should be using something other than
"Comp.Tech.Quer yResultGrid.Res ultsGridDrag.bm p"?

--

Cheers,

elziko

Nov 20 '05 #2
* "elziko" <el****@NOTSPAM MINGyahoo.co.uk > scripsit:
I'm trying to use an embedded image(bitmap) using the following code:

imgDrag = New
System.Drawing. Bitmap(GetType( QueryResultGrid ).Assembly.GetM anifestResource S
tream("Comp.Tec h.QueryResultGr id.ResultsGridD rag.bmp"))

Where QueryResultGrid is the class thats going to use the image,
Comp.Tech.Query ResultGrid is the assembly name and ResultsGridDrag .bmp is
the file name of the embedded resource. However, on runing this line 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'.

Any ideas why? I think that maybe I should be using something other than
"Comp.Tech.Quer yResultGrid.Res ultsGridDrag.bm p"?


Does it work it you use something like that?

Add the image, set its 'Build Action' to 'Embedded Resource', then you
can use this code to load the bitmap:

\\\
Me.picMyPicture .Image = _
New Bitmap( _
System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetManifes tResourceStream ( _
"<Root namespace>.<Fil e name>" _
) _
)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

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

Similar topics

0
761
by: Philipp Seidel | last post by:
Hi there! I did not know, where this topic fits in, so I put it here. I have a minor problem with embedded resources, which puzzles me quite a lot. I'd be glad if anyone can help me on this: I've added a few files (images) to an assembly as embedded resources. Within the project folder these files are in a subfolder named "images".
1
3417
by: unotin | last post by:
I have an application in ASP that exports to Word using the Response.ContentType method. The application references another ASP page through the img tag that uses a Response.BinaryWrite (of an img content type) for its output. In other words: App A.ASP contains the code: <%Response.ContentType = "application/vnd-msword"%> <img src="B.ASP">
1
7496
by: Zeroeffect | last post by:
Hello! I have a database with alot of embedded images. The reason for having the images embedded is security. My problem is that it works fine on my computer, but not on my clients computer. He hasn't got Microsoft Photo Editor installed and because of that he cant view the images when doubleclicking on them in the table. He can still see the pictures in the formview but when he doubelclicks the images a error message shows up.
0
989
by: Tom | last post by:
I'm creating a demo database with three records. The finished database will have linked images but for the demo I want to keep everything in the same file. How do I create three embedded images, one for each of the three records so that the actual image files do not have to be distributed with the database file? Thanks, Tom
1
1485
by: Hans Kesting | last post by:
Hi, I know how to send emails from the .Net environment, even html mails. But, what is the best way to add images to the html? A URL to an image somewhere on some server is usually blocked nowadays, so you need to send the image as attachment. I had some success when I used the filename (without path) of the attachment as img-src. Is that the only way or are there better methods?
0
1385
by: Vladi | last post by:
Hello everybody, I have a asp.net 1.1 page which has the following controls: 4 Images whose src points to an image.aspx file which returns a different jpg from a DB 1 flash object on top of those which contains buttons with links embedded in them to another pages (each having the same layout, identical to the page I'm talking about). The transfer is realised with some url_get method in the flash. I don't know because I didn't make it and...
2
1413
by: Grant Harmeyer | last post by:
I have a project where I am required to embed a few images and CSS files in the assembly (v1.1) and read them out at runtime. I know that this can be done using an HttpHandler/.axd file (like the one used for FreeTextBox http://www.freetextbox.com), but I've never tried this before. Does anyone have any sample code for this? I know they've made this much easier in 2.0. -- Grant Harmeyer
7
4444
by: Trapulo | last post by:
Hello, I need to send an email from vb.net. The body may be html encoded, and all images related to the html (<img src....>) may be embedded in the email content instead of refer to remote urls. I've tried a lot of solution, but I can only get a message with images embedded but no html, or message with html but no images embedded. What is the right way to have this goal? I have a dictionary with <image name, image content as byte...
1
1928
by: mark | last post by:
I'm using System.Net.Mail to send HTML email. I have a few images embedded within the HTML body. What's the most efficient way of including these images with the message or getting the images to display on recipient's client? Obviously, I want to avoid spam filters and don't want to hog bandwidth. Any help much appreciated.
8
2458
by: Fred* | last post by:
Hello, I'm using Visual C# 2005 Express. if I create a new "application windows" project and run it (F5), it works well. (an empty window is launched..) as soon as I set the build action to embedded resource, I can't run it anymore because I got an error on 'WindowsApplication1.Form1.Dispose(bool)'..
0
9706
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
9577
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
10569
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...
0
10325
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
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,...
1
7615
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
6847
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
5519
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
4295
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.