• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

Icons already in the EXE

In the project properties, I set my application's default icon which, in turn, added it to the resources or whatever you want to call it.. it's compiled in with the exe.. I plan on doing this with all my icons but I need to know how to get the icons in the form of System.Drawing.Icon so they can be accepted in most controls. Thanks in advance.
0
UrbanPuppet
Asked:
UrbanPuppet
  • 5
  • 3
1 Solution
 
gregoryyoungCommented:
dim stream as Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("namespace.objectname")
dim i as Icon = new Icon(stream);
0
 
UrbanPuppetAuthor Commented:
Stream isn't a type, so that code isn't working; how would I get it to work?
0
 
gregoryyoungCommented:
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
gregoryyoungCommented:
are you importing System.IO ?

what about System.Reflection for the assembly class ?

0
 
UrbanPuppetAuthor Commented:
Ok, sorry, did that and now it's almost working, I just don't know what to put for namespace.objectname .. the project is called XSM and the icon is called icoMain.ico but XSM.icoMain.ico didn't work. I've raised the points a little too.
0
 
gregoryyoungCommented:
What is the default namespace for your project ?

Also it is case sensitive ...

http://www.dotnetspider.com/Technology/KBPages/442.aspx gives further examples of using GetManifestResourceStream.
0
 
UrbanPuppetAuthor Commented:
OK, thanks, that link helped a lot.. But i had after I tinkered with your first post.. I just needed to change the icon to an embedded resource..

The final code ended up like this:

Dim Stream As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("XSM.icoMain.ico")
Dim i As Icon = New Icon(Stream)

frmMain.Icon = i
0
 
gregoryyoungCommented:
you could just use

imports System.IO
imports System.Reflection

glad you could get it working ...

Cheers,

Greg
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now