views:

129

answers:

2

Hello,

I'm using VS2008 C#.NET.

I created 3 different classes of libraries in 3 projects. I wrote an application which uses these libraries (dlls).

What is happening is each project is compiling into a class library. So, I've 3 dlls and 1 exe.

Instead I want to have these in two ways:

  1. Only class library assembly (dll) which contains 3 of them and 1 exe.
  2. just one EXE (everything inside it) :: static linking.

How could I do that? I cannot find any options for static linking in VS2008 also please mention commandline options too.

+4  A: 

Ilmerge is what you're after.

I'm not sure I'd really call this "static linking" - it's just merging several assemblies into one. (In particular, please don't get the impression that this is building a native, unmanaged executable.) However, I think it's what you're after :)

Jon Skeet
I believe that in *nix land, an executable without dependencies on dynamically-loaded shared objects is called "statically linked"
orip
when its just one assembly whats problem in referring it as "static linking"? Because everything is linked into one and is along with my executable (I mean they are not shared) and everything is loaded at once too.
claws
@orip: My view of static linking is more than that though; linking in .NET is still somewhat dynamic - there's more to be fixed up at execution-time than with a statically-linked native executable.
Jon Skeet
+3  A: 

You can place all of your code into one EXE project, use a third-party linker (google .net static linker for a number of options), or use ILMerge as illustrated here.

The third-party linkers generally also offer code obfuscation, and some can also statically link the .NET Framework.

Eric J.