1

I'm generating an executable file with VB.NET using CodeDomProvider.

Is there a way to change the icon before the compiler creates the exe file?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Lullly
  • 91
  • 3
  • 4

3 Answers3

3

You can set the icon of the generated exe by specifying it in the CompilerParameters that you pass to the code provider, using the CompilerOptions property.

Dim parameters As New CompilerParameters()
parameters.CompilerOptions = "/win32icon:C:\full\path\to\icon.ico"

You then pass these parameters to the CompileAssemblyFromSource method. The generated exe will then use the specified icon as its application icon.

adrianbanks
  • 81,306
  • 22
  • 176
  • 206
  • thanks man, i will try now to see if it works LE: it works perfect, thanks a lot man – Lullly Jan 30 '10 at 15:34
  • When i do this, and compile the code, i get an error: Source file 'Deployment' could not be found. If i remove this option and only keep /optimize, it compiles without issues. Is there something i'm not doing correctly? – MaxOvrdrv Jun 02 '15 at 13:55
  • Actually never mind... apparently for compiler options you must use short path names (8.3 format) for paths. – MaxOvrdrv Jun 02 '15 at 14:10
0

Go into the project properties and select the icon from there. Simple as that.

Gabe
  • 49,577
  • 28
  • 142
  • 181
  • man, i have an VB 2008 application with a textbox. There i wrote some VB code and when i press GENERATE, the application use codeDom Compiler and generates an exe with that code from the textbox. The file is an exe with an exe icon, and i want to change it somehow. it's not just a Icon property of an form or application – Lullly Jan 29 '10 at 20:06
0

You can use RessourcesHacker AFTER the generation. Not the easiest way, but it works great

P1kachu
  • 1,077
  • 3
  • 11
  • 33