简体   繁体   中英

Internalize Class and Methods in .NET Assembly

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

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 here .

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.

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM