Thomas
Thomas

Reputation: 34198

class library and security in dotnet technology

suppose i have developed class library and i want the i can use this library in my project only but if someone try to copy the dll file and want to use it in his project then he will not be able to do so. so i just want to know how could embed this type of security in the dll file...please tell me all ways. thanks

Upvotes: 5

Views: 1566

Answers (4)

Stefan Steiger
Stefan Steiger

Reputation: 82276

Check the signature of the calling assembly and sign the assembly you are calling the dll from. Then sign the dll.

Upvotes: 3

Martin Buberl
Martin Buberl

Reputation: 47144

You could verify in your assembly the PublicKeyToken of the calling signed assembly.

The second example is in VB.NET, couldn't find a C# version readily but you'll get the idea.

Be aware that this is not an absolutly secure way, because someone could still decompile your assembly. But if it's just to prevent that your library is used in other projects, this might be an acceptable way.

Upvotes: 5

k3b
k3b

Reputation: 14755

Not secure but much harder to abuse: You can integrate the dll into your main exe or web.dll using

Upvotes: 2

Chris B. Behrens
Chris B. Behrens

Reputation: 6295

You could invoke a licensing technology when the library was to be instantiated. What I've done in the past is include a public key as a resource to the dll, and then look for a license xml document with a cryptographic signature signed with my private key. As long as I keep close track of my private key, it's pretty difficult to defeat.

Having said that, .Net is eminently decompilable - be sure and obfuscate it with a tool like Dotfuscator.

Upvotes: 2

Related Questions