views:

354

answers:

3

Possible Duplicate:
How to protect dlls?

I am wondering how I may protect my DLL files from being used by other people. By "used" I mean, referenced/imported or whatever into projects and the functions and variables inside used.

I only wish it to be used by my applications... is there a way to protect it?

A: 

Make all types internal, mark them with InternalsVisibleToAttribute so that they are accessible from your assemblies only.

However, this is very strange what you're trying to do. Why don't you just compile classes in questions directly into your application?

Anton Gogolev
A: 

I believe you will want to look into Code Access Security. I have not done anything with it myself, so I am interested to know how your experience goes with it.

Matthew Vines
A: 

I have seen DLLs where a method is provided within the DLL that takes a security code that unlocks the DLL. The security code can be a parameter within the constructor of your classes. You can make this as elaborate as you want, using methods from the Encryption classes in the framwork if you wish.

Of course, since .NET DLLs can be disassembled, there's no way this can be made absolutely bulletproof, but it would protect your DLL from everyone but the most persistent of hackers the honest people.

Robert Harvey