views:

135

answers:

4

Hello,

currently I develop a C#.Net application in which I'm using a custom control I developed some time ago. I need the dll to be shipped within the new application - but understandably I do not want the dll file to be used for foreign apps.

That's why I need the custom dll to be somehow compiled within the new application. Currently the dll is copied into the application directory.

Any ideas? Should be trivial imho.

Thanks & regards, Daniel

+4  A: 

I think you need to be looking into licensing your control(s): http://msdn.microsoft.com/en-us/library/fe8b1eh9.aspx

Wayne
thanks for all these replies - I'll try this one and come back if nessecary.
dhh
+3  A: 

Look into IL Merge. This utility allows you to combine multiple .NET assemblies into a single assembly.

I quote:

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.

Something to take into consideration however, is that people can still use the created assembly. Look into obfuscation and licensing to keep the easy-going at bay, but remember that if someone wants your code badly enough they will get it.

Certain things make it a lot harder, such as having a Web Service, but even then this is not full proof.

Kyle Rozendo
A: 

If you can change the DLL with the proprietary control, you can...

  1. Mark everything in the control DLL internal.
  2. Compile your assembly so that your calling DLL has access to the internal members of your control DLL.
  3. Sign the calling DLL.

See this MSDN page for the details on how to do this.

RichAmberale
A: 

There's a number of different hacks you can do to make this harder for folks to use. All of them can be circumvented, but such is life.

You can look at this response here for disallowing an unknown assembly to reference your assembly: http://stackoverflow.com/questions/2806842/secure-c-assemblies-from-unauthorized-callers

You should obfuscate your assembly if you are really nervous about it. This will make it harder to decompile. Something like Babel works great: http://babelobfuscator.blogspot.com/

You can also use ILMerge to store the assembly in another assembly. However, this assembly will be extracted and exposed at run-time. You can do something along these lines to extract a binary resource from one assembly and create a temporary assembly that gets used at runtime. If someone is really motivated, they can find the temporary assembly as well...

The real question is how far do you want to go!? At some point it won't be worth it. That's where you stop.

Scott P
Hum, I don't want to go real far - all I want is the dll not being visible in the app directory at first glance or somehow protect it against embedding it easily. I know: everything made by humans can be hacked or destroyed by humans. If Microsoft, Apple and other large companies are not able to achieve real protection against hacking their software - how can I event think of being able... ;-)
dhh