Click here to Skip to main content
15,355,133 members
Articles / Programming Languages / Visual Basic
Posted 30 Mar 2003


27 bookmarked

Using embedded resources with .NET

Rate me:
Please Sign up or sign in to vote.
2.72/5 (22 votes)
30 Mar 2003
Using embedded resources with .NET.

Sample Image - EmbeddedIconDemo.gif


Embedded resource in a project is a new thing in .NET. This sample shows how to use it.

Using the code

The form has a button which changes the form icon.

Dim oStream As System.IO.Stream
Dim oAssembly As System.Reflection.Assembly
Dim sIcon As String
Dim oBitmap As Bitmap

If vbON Then
    sIcon = "EmbeddedIconDemo.LIGHTON.ICO"
    sIcon = "EmbeddedIconDemo.LIGHTOFF.ICO"
End If

'open the executing assembly
oAssembly = System.Reflection.Assembly.LoadFrom(Application.ExecutablePath)

'create stream for image (icon) in assembly
oStream = oAssembly.GetManifestResourceStream(sIcon)

'create new bitmap from stream
oBitmap = CType(Image.FromStream(oStream), Bitmap)

'create icon from bitmap
FetchIcon = Icon.FromHandle(oBitmap.GetHicon)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Sander Schreurs
Web Developer
Netherlands Netherlands
I started with VB4 in 1996, after that VB5 and VB6. Always advanced database applications (Oracle, Access and SQL-Server). The last 5 years as a technical architect and project manager for development teams.

Special interest for user interaction.

Comments and Discussions

GeneralMy vote of 5 Pin
drummerboy051125-Mar-11 11:32
professionaldrummerboy051125-Mar-11 11:32 
It works quite nicely!
Generalhello^^ Pin
Demantorr17-Jan-10 13:06
MemberDemantorr17-Jan-10 13:06 
GeneralWrong title Pin
-R-y-a-n-28-Oct-07 1:25
Member-R-y-a-n-28-Oct-07 1:25 
GeneralAlways getting error when added new icon Pin
yj80018-Aug-07 22:39
Memberyj80018-Aug-07 22:39 
GeneralThis worked for me :) Pin
3DWebGuy9-Jun-05 10:32
Member3DWebGuy9-Jun-05 10:32 
GeneralSame problem with cursors Pin
mfortin4-Sep-03 22:52
Membermfortin4-Sep-03 22:52 
Generalshowhelp embedded resource chm file Pin
mdg1710-Jul-03 8:08
Membermdg1710-Jul-03 8:08 
GeneralMinor Improvement Pin
Sander Schreurs31-Mar-03 4:55
MemberSander Schreurs31-Mar-03 4:55 
GeneralTell More Pin
Poolbeer30-Mar-03 19:43
MemberPoolbeer30-Mar-03 19:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.