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:
How could I do that? I cannot find any options for static linking in VS2008 also please mention commandline options too.
Static linking is the result of the linker copying all library routines used in the program into the executable image. This may require more disk space and memory than dynamic linking, but is both faster and more portable, since it does not require the presence of the library on the system where it is run.
In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.
A static library is a file containing a collection of object files (*.o) that are linked into the program during the linking phase of compilation and are not relevant during runtime. As shown in the diagram above, when a program is compiled, the compiler generates an object file from a source file.
Static Linking and Static Libraries is the result of the linker making copy of all used library functions to the executable file. Static Linking creates larger binary files, and need more space on disk and main memory.
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 :)
Update: ILMerge is now open source and is also available as a NuGet package:
Install-Package ilmerge
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With