开发者

.NET Assembly Dependencies

Perhaps I am missing something obvious here but...

I have built a reusable generic C# class library project say (A.dll) which references 3 other assemblies say (B.dll, C.dll and D.dll)

However if I want to reuse my component A.dll in another project I still have to include the references to B.dll, C.dll and D.dll.

Is there any way you can configure A.dll to bu开发者_C百科ild all its dependencies into the A.dll so I don't have to include the other 3 assemblies?

Cheers


It's possible to merge assemblies, using the tool ILMerge:

C:\Program Files\Microsoft\ILMerge\ILMerge.exe /target:library /out:abcd.dll a.dll b.dll c.dll d.dll"

This will merge the dlls a, b, c and d into abcd.dll. It will also merge the debugging symbols but not the XML documentation.

Also you'll have to reference the dll itself in new projects and not the respective projects. An exception to this is if you merge libraries into an executable, in that case you can reference the respective libraries/projects because they will be loaded with the executable.

The Mono Project also has a tool for this, called mkbundle.

Also available is ILRepack, which aims to be compatible with ILMerge, but is FLOSS.


This would be something like static linking of DLLs which works fine with native C++. As far as I know you cannot statically link assemblies in .NET code, thus you have to include all DLLs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜