Cute
Cute

Reputation: 14021

How to statically link libraries for a C# ClassLibrary?

I am creating a Class LLibrary in c# by using microsoft provided Dll's.

Now i want to statically add those Microsoft provided libraries to My Dll.How can i do this. I have simply added a reference to those Microsoft provided Dlls and creating My Dll? Is it fine or not?

if Microsoft provided dll is not available on other machine then my Dll may fails i need to add the libraries statically??

How can i do this??

Upvotes: 7

Views: 13118

Answers (3)

MSIL
MSIL

Reputation: 2761

Its not very clear what you want to achieve but it seems you are concerned that your class lib will work on some other machine or not. The thing is that the .Net framework is a free redistributable which should be installed if not present on the target machine. With the .Net framework already installed on a machine, there should be no problem as such.

Static linking as such does not make sense in .Net other that adding an assembly reference to your project. Hope it helps

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1063198

If the dll is not available at execution time; yes it will fail. However:

  • many Microsoft dlls are pre-installed with .NET (caveat: "client profile")
  • many of the Microsoft dlls are redistributable; so you can include them with your package

There isn't a linker provided in the core framework, although ILMerge may be useful.

Upvotes: 3

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422076

There's no such thing as statically linking to another assembly in .NET. There are some third party products such as .NET linker that merge assemblies into one but they are unsupported.

If you have the redistribution license for that library, you can ship a copy along with your assembly. In Visual Studio you can make this happen by setting "Copy Local" to "True" in the properties window for that assembly reference.

Upvotes: 7

Related Questions