Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Static Libraries

Tags:

c#

dynamic

static

When I use to program in c, the difference between a dynamic library and a static one was the way you compiled the program in the makefile. Dlls, as we know, are not hard coded into the app, but are in separate files. Which makes them perfect for update and adding functionality to a program. Static libraries on compile time are hard coded into the app. Which is perfect for a behavior that will not need to be changed in the future: like security or basic communication.

I know how to create and call .dll files in c#, but I need to create and use static libraries. Is there anyway to do this without copy/paste a class library into each project ? I have a lot of projects that use these static libraries, and I want to avoid having to change all class libraries when I introduce a change.

I googled this, but came out with no solution.

Thanks alot...

like image 586
Fares Avatar asked Aug 23 '11 10:08

Fares


1 Answers

The closest you can come is ILMerge - but do you really need this? Unless you have an application which you can deploy as a single executable, it doesn't much matter whether you have one DLL or ten. I would suggest that for most cases, you should just keep them as normal class libraries.

Note that ILMerge isn't quite the same as "static linking" - it still does the job of bundling all the code into a single file, but the linking process in .NET is fundamentally somewhat different to the one for native code.

like image 66
Jon Skeet Avatar answered Sep 28 '22 16:09

Jon Skeet