Protecting my DLL

durgesh

New member
Joined
Nov 30, 2005
Messages
2
Programming Experience
1-3
Hi Everyone...
I want to protect my class library from being used by others (developers). I want to create a dll for my own use i.e. inside my projects only or solution having many projects....but i donn want that other can use my dll.
Overall, I want to hide my dll properties/methods from other developer...So, how could i do this..? Please help me..
Thank you.
Bye!
 
You have to make the types, properties and methods that you want to use Public so that you can use them, which means that others can use them too. If you don't provide documentation and obfuscate your code then it will be more difficult, but not impossible, for others to work out what your code does, but they can still use the same types, properties and methods that you do. You might want to look into a licensing system, which will allow you to ensure that noone without a valid license can use your assembly. You'll almost certainly have to pay for that though, and the really good systems are valued in the thousands. You won't need to pay that much, but I doubt you'll find anything genuinely useful for free.
 
Protecting & Licensing DLL

so the only way to protect my dll public methods and properties is by licensing the dlll........so how could i do this......can i have some example......
please help me...
Thank you.
 
You need to purchase a licensing component and integrate it with your own software. I can't give you a code example because every one will be different. Two of the big players are Xheo and Desaware, but they are both very expensive. Many developer sites have components you can buy, including licensing components. Start Googling and do some research.
 
durgesh said:
so the only way to protect my dll public methods and properties is by licensing the dlll........so how could i do this......can i have some example......
please help me...
Thank you.

No, protecting your code is by Obfuscating it. Preemptive has a product called "Dotfuscator" which is included in VS.NET, although a scaled down "Community Edition." If your code is valuable, you may want to invest in the Standard or Professional Edition of Preemptive Dotfuscator. I personally use the Professional Edition and swear by it!
 
The impression I got was that durgesh was asking how to stop other developers referencing his assembly in their projects. If that's the case then obfuscation is not of too much use. As I said previously, obfuscation will make it more difficult for someone else to determine your source code, but if they know the interface then they can use the assembly just like any other. If they know the names of the types and the public members they expose then they are free to use them, obfuscated or not.
 
Just my opinion here but i use 'Code Veil' it's by far the best one i've used. Assemblies that are reverse engineered after using it are completley unreadable. Not sure how well it stands up against Salamander but as manic says if people want to get a hold of the source there is nothing that will stop them. Besides any hacker that is worth *it* can read x86/IL anyway.
 
Last edited by a moderator:
ok take this carzy idea
for each function you have in your dll
add an argument to it like
public function XXXXX(byval yourvar,byval licenskey as string)
and make your oun string
and then for the begin of each function make that
if licenskey <> "your oun string" exit function


and soo on
 
Ok, say that I theoretically want to write my own licensing component. Can someone explain what the main issues are with this?

First of all, there's the question of what the license key is tied to? For example, is it just a secret key that gives the user a blank check to use on as many machines as he wants? Is it a per-seat license? A per-machine license? A demo license, i.e. tied to an expiration date? Presumably the key is a hash that is generated based on some set of criteria...

Then, once you have the license key, a method to generate it, and a method to check it, how does it integrate into code? Is it just a simple if statement, i.e. something like,

VB.NET:
If CheckLicense(key) = False Then
    Throw New LicenseFailureException()
End If

Or is there something more complicated involved?

Just wondering.
 
Just put the license inside the Constructor. If the contructor isn't valid fire an exception there. Don't check for every function, that's a waste.

VB.NET:
Public Class MyClass
 
     Public Sub New(ByVal LicenseKey as String)
          If not LicenseKey = "YourKeyHere" then
                Throw New System.Exception("License Rejected")
          End If
     End Sub
 
End Class

Another wise option would be to place a global variable friend const in the namespace of your .dll and quietly check for the key behind the scenes like so. This means you would only have to assign the serial key once for the entire library and not for every new class being instantiated. This is my preffered method.

VB.NET:
NameSpace  MyLibrary
     Public Module SerialKey
          Friend Const MY_SERIAL_KEY as String = "your key"
          Public SERIAL_KEY as String
          Friend Sub CheckKey()
               If SERIAL_KEY <> MY_SERIAL_KEY then
                    Throw New Exception("Invalid Serial Key")
               End If
          End Sub
     End Module
 
     Public Class MyClass
          Public Sub New()
              CheckKey()
          End Sub
     End Class
 
End NameSpace
 
Last edited:
Back
Top