SmartAssembly 8

Merging dependencies

Dependencies merging integrates the code of a dependency with the code of the main assembly. After merging, the dependency is inseparable from the main assembly.

You can obfuscate and prune the code from a merged dependency in the same way as code in the main assembly.

Using dependencies merging

To merge dependencies, in the Project Settings window, go to Dependencies Merging or click the icon in the toolbar.

Select the dependencies to merge. To refresh the list, click Rescan dependencies.

If you select a dependency, which itself has dependencies that are within the list, these are automatically selected.

When dependencies merging is enabled, the colored bars under the toolbar icon and to the left of the features options are green. The colored bars for dependency embedding also turn green when you enable dependencies merging because merging is preferred over embedding. If merging is disabled, the bars are orange.

If you experience problems using merging, see Troubleshooting merging problems.

 

 

Merging example

The following example shows code before and after merging DLL1 and DLL2 into MainExe:

Before merging:

DLL1:

internal class InvalidDocumentContentsException : Exception
public sealed class DiscoveryDocument;

DLL2:

internal class InvalidDocumentContentsException : Exception
internal class LinkGrep

MainExe:

public sealed class DiscoveryClientResult
internal struct CallId

 

After merging:

MainExe:

public sealed class DiscoveryClientResult
internal struct CallId


internal class InvalidDocumentContentsException : Exception
internal sealed class DiscoveryDocument

internal class InvalidDocumentContentsException : Exception
internal class LinkGrep

 

What is the difference between merging and embedding?

Merging

When you merge a dependency with the main assembly, the code from the two assemblies are merged into a single assembly. The resulting assembly does not contain a reference to the dependency. Calls are no longer public (by name) but internal (by member ID), which provides greater protection and is quicker.

You can protect a merged dependency by obfuscating the whole assembly in the normal way.

Embedding

When you embed a dependency, it is stored in the main assembly. Optionally, you can also compress and encrypt the dependency's contents. If you embed a dependency, the main assembly is not modified.

At runtime, the first time the DLL is needed, it is unencrypted and decompressed (if applicable) and then an assembly is created and loaded into memory. The embedded assembly keeps its identity and its integrity.

To protect the dependency, first protect it in a separate SmartAssembly project and then embed the obfuscated DLL. 


Didn't find what you were looking for?