Hi I have a quick question, I tried asking on the MSDN forums and they were no help.

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?


Thankyou for any help you may give me.

Unfortunately, it is a needlessly large complicated topic, which I think most people avoid unless they really need it. Thus, the reason for your lack of help in other forums. But I think if you do research on Code Access Security and C# you may be able to do what you want.

Just seems so absurd this kind of thing isn't already built-in.. I mean.. dlls are supposed to be useful to the programmer so he can share things between his applications but not everyone else... :/ it annoys me the .net language is so open too... you can decompile the apps so easily it's not worth the effort inventing new functions just to have them stolen.

There's actually an easy method in the CLR to limit the use of your assemblies to only your projects. Take a look at the PublisherIdentityAttribute in the docs. This will limit the use of your assemblies to assemblies signed by your private key - effectively limiting the use to those you authorize.

Of course with all the other security weaknesses in .NET this can be circumvented without proper proptection of your assembly. You'll want to take a look at an obfuscation/encryption tool to make sure the strong names can't be modified. CodeVeil - by XHEO where I work - will do just that.

How do I sign it with a key?
I implemented a simple byte array keycode with xor functions... it's not perfect and could be found if you look inside.

Is codeveil free?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.