Click here to Skip to main content
Click here to Skip to main content

Merging DLLs into Your Main Assembly for Easier Distribution

By , 2 Apr 2012
 

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Compiling .NET code often results in multiple assembly files being created, including satellite DLLs, all of which are required for the program to run. While this is a non-issue during development, when it comes to deployment it often means an unwanted stage of users having to unzip files, or manually move certain DLLs to specific places.

SmartAssembly is capable of merging the code from referenced DLLs into the main assembly, producing a single application for deployment and so greatly simplifying the process.

When merging dependencies, SmartAssembly completely integrates the dependency code into the main assembly code. Instead of making public calls (by name), the resulting assembly instead makes internal calls by Member ID. As well as making deployment easier, this also provides some level of protection against people examining and reverse-engineering sensitive code.

Merging referenced DLLs is a simple process. After adding the main assembly to a project as the input, and selecting an output destination, SmartAssembly automatically scans for dependencies and presents a list. We select the DLLs we wish to merge and click ‘Build’ to generate the output file.

Merging-DLLs/image001.png

Figure 1: Merging assemblies with dependencies in SmartAssembly

There are some limitations to what can be successfully merged. For example, some third-party DLLs will include integrity protection, which causes the DLL to fail to load as its contents will appear to have been modified.

For these instances, SmartAssembly supports dependency embedding, which allows referenced DLLs to be embedded into the main assembly as resources, instead of being merged into the main assembly’s contents. It is also capable of compressing these resources and dynamically uncompressing them at runtime, significantly reducing the distributed file size.

Merging-DLLs/image002.png

Figure 2: The difference between merging and embedding assemblies

As well as merging and embedding dependencies, SmartAssembly can apply powerful obfuscation to assemblies, preventing malicious users from decompiling them. It can also add Automated Error Reporting, a sophisticated mechanism for receiving reports of any unhandled exceptions which occur when your application is used in the wild, along with all the data needed to diagnose them.

SmartAssembly can be controlled through the command-line, so it is easily integrated into the build process, providing simple, reliable merging of dependencies on every build.

Learn more about SmartAssembly, or download your free trial.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Red Gate Software
Red Gate Software Ltd.
United Kingdom United Kingdom
Member
Organisation
4 members

Red Gate Software produces ingeniously simple tools for Microsoft technology professionals worldwide. We currently specialize in MS SQL Server, Cloud, .NET and Oracle database tools. Established in 1999, we are based in the beautiful, if rather flat, university town of Cambridge, UK

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionSmartAssembly Doesn't seem work perfectly.memberVijayBabuM8 Jul '12 - 8:48 
I've tried smart assembly in vb.net project where I want to merge/embed AutoItx3.dll assembly in my main assembly project.exe.
 
It works in windows XP, without any problem.
But in all windows 7 machine the error it says is this.
"System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {1A671297-FA74-4422-80FA-6C5D8CE4DE04} failed due to the following error: 8007007e."
 
I didn't find any reference to this issue so far. Can anybody provide a solution?
QuestionILMergemembercrashedapp31 Jan '12 - 4:46 
How is this different than ILMerge?
AnswerRe: ILMerge [modified]memberslaphead993 May '12 - 4:31 
ILMerge is not exactly friendly. Plus this article also discusses an entirely different technique called 'embedding'.

modified 3 May '12 - 10:42.

Questiontry .netshrinkmemberBartosz Wojcik22 Jan '12 - 23:57 
try .netshrink faster, easier, cheaper - http://pelock.com/products/netshrink/screenshots

AnswerRe: try .netshrinkmemberslaphead993 May '12 - 4:37 
This is nice but Smartassembly is also an obfuscator.
GeneralRe: try .netshrinkmemberBartosz Wojcik4 May '12 - 23:15 
Don't you know *ALL* obufscators for .NET are worthless since de4dot project is up? It's an deobfuscator and supports every known obufscator:
 
https://github.com/0xd4d/de4dot/downloads
 
Run your obfuscated assemblies thru de4dot then open them in .NET Reflector = clean code

GeneralRe: try .netshrinkmemberslaphead995 May '12 - 10:10 
I don't believe this is 100% accurate- I have several perfectly good managed DLLs that cause de4dot to crash. And anyway- you can't believe this either since you sell an obfuscator and have obfuscated your code.
GeneralRe: try .netshrinkmemberBartosz Wojcik5 May '12 - 11:36 
It might be not 100% accurate, but accurate enough to understand the code / crack it. .netshrink is NOT an obfuscator, it's exe-packer/dll binder/password protector ONLY.

GeneralRe: try .netshrinkmemberslaphead995 May '12 - 11:46 
Misunderstandings galore. I simply asserted that you obfuscated your code therefore you must have some faith in obfuscation.
GeneralRe: try .netshrinkmemberBartosz Wojcik5 May '12 - 12:36 
To be honest it's security by obscurity in my opinion and it can stop only newbies.
 
de4dot is perfect example why managed protection sucks Smile | :)
 
I never saw similar tools for x86 (native images) binaries (except single, custom, for the single version and often non working and hard to use), simply because the difficulty level is much much higher

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 2 Apr 2012
Article Copyright 2012 by Red Gate Software
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid