Welcome to MSDN Blogs Sign in | Join | Help

David Szabo's [MSFT] blog

A Consultant's Diary
How to build/link multiple DLLs and an EXE C# projects into one EXE assembly

This is just a quick reference. A couple of blogs mentioning how to do that, but they forget to mention what to do if you have a Windows application (all examples are done with Console apps). So, here it is, briefly:

Let's say, I have 2 projects, one DLL and another one is an EXE Windows application project. I'm referencing the DLL project from the EXE project. Here's how to build and link them together:

1. Build all of you projects (including the EXE project) into netmodules:

cd DllProject

csc.exe /target:module *.cs

cd ../ExeProject

csc.exe /target:module *.cs /addmodule:../DllProject/Class1.netmodule

2. Link them together (and here's the trick that the Windows EXE project also has a Program.Main entry point but you don't see this one):

link /LTCG /verbose /entry:ExeProject.Program.Main /out:SingleFile.exe Form1.netmodule Class1.netmodule /subsystem:windows

Posted: Friday, April 20, 2007 8:20 PM by dszabo

Comments

Smartwombat Blog said:

This is something what I wanted to figure out for quite some time now, but my friend dszabo at microsoft...

# April 21, 2007 6:59 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker