views:

113

answers:

4

I want to deploy an application with a license attached. However, I want to prevent that my dll can be easily referenced in visual studio.

What are the usual ways of doing this? I was thinking about ngen-ing the application to prevent this, however, then the code becomes architecture dependent. Im not targetting any other architecture/platform besides windows, however, ngen-ing the application after making a release build seems like a workaround to me. Are there any other techniques to achieve this?

A: 

If you are using an installer, you can ngen during installation. SQL Server does this.

You can also obfuscate. It doesn't prevent linking per se, but it does make it difficult to know what the dll does, reducing its "usefulness" to other processes.

Cylon Cat
nobugz says that ngen-ing doesnt make sense since the original assembly should also be present.
Henri
@Henri, thanks for the correction! I'll remember that.
Cylon Cat
A: 

What if you change the scope of your classes to Friend

Gratzy
+2  A: 

Code access security (CAS). You can enforce a LinkDemand, all the way down a chain of inheritence or methods or assemblies, that requires that all assemblies linking have the same strong name key and other evidence as you require.

Richard Hein
Good idea, i will try to see what i can do with this
Henri
+3  A: 

You can't ship an ngen-ed image, Ngen.exe must run on the target machine. There's a dedicated service, installed by the .NET installer that takes care of it. It doesn't help protect anything anyway, the original assembly must still be present as well.

.NET has built-in support for licensing but it only works for designable classes. System.ComponentModel.License is the base class declaration. LicFileLicenseProvider is a concrete implementation of it.

You can buy something 3rd party, dongles are unbeatable. Either way, the only true protection you'll get for your IP is in a court of law. Claim copyright in a visible place, ensure your user goes through an explicit license agreement step before using your code.

Hans Passant
+1 "the only true protection you'll get for your IP is in a court of law."
C. Ross
Thanks for the info. Although I dont agree with the fact that dongles are unbeatable, however, it doesnt matter for this case. Ill try to get more info on the License class and see what it can do for me. Moreover, ill try to combine it with code access security.
Henri