views:

572

answers:

5

I have a set of multiple assemblies (one assembly is to be used as an API and it depends on other assemblies). I would like to merge all assemblies into one single assembly but prevent all assemblies except the API one to be visible from the outside.

I will then obfuscate this assembly with Xenocode. From what I have seen, it is impossible to internalize assembly with Xenocode.

I have seen ILMerge from Microsoft, but was unable to figure if it can do what I want. http://research.microsoft.com/~mbarnett/ILMerge.aspx

A: 

How about you make all your other classes (which you are trying to internalize) as private sub-classes of the main assembly classes which are going to be using them.

How would you do that? If I make them Private, they won't be accessible between assemblies?!

Vincent
+1  A: 

I know Xenocode can merge assemblies into one but I am not sure if it will internalize other non-primary assemblies.

I have found the /internalize switch in ILMerge that "internalize" all assemblies except the primary one. Pretty useful!

Vincent
+2  A: 

I have used ILMerge from microsoft to internalize DLL's into a single assembled library. There is a useful GUI for using ILMerge called NuGenUnify. You can find it at http://www.genetibase.com/cforce/nugenunify.php

John Chuckran
+1  A: 

I suggest you look at the InternalsVisibleTo attribute on MSDN.

You can mark everything in all the assemblies (except the API assembly) as internal instead of public, then reshow them to just your API assembly.

Having done that, using ILMerge should give you a single assembly with just the API classes visible.

Ant
+1  A: 

There are some issues with ILMerge, but I think if you add optimisations + merge + obfuscation you're likely to create a highly complex situation for little benefit.

Why not have just one assembly, and make only your API public?

If you're always distributing them as a single assembly there's no reason not to just compile them as that. You'll get more benefit from compiler optimisations and it will be quicker to compile too.

Keith