Protecting class library DLL from design time use

I'm currently developing a VB.NET class library DLL which I'm going to use with an application... however I want to protect others from referencing it and using it during design time.

Does anyone know of a way to do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

add one member variabe in  dll's class
 which will contain applications name
  whenever u use that dll u should provide application name in constructor
  if provided application name is application n name for which u want to give access to dll then only allow user to use this dll

class testdll
  private ApplicationName;
   public testdll(string Appname)
  public string MemberFun()
        return "U r not Allow to use this dll";
There are many ways to protect your components and to manage licenses.  I like to inherit from the LicenseProvider class because you can implement a simple code or a very complex algorithm.
You should read about the LicenseProvider class and it's implementation, but I will show you the general concepts to implement the class and the basic considerations you must have.

1.  Create a class that inherits from System.ComponentModel.LicenseProvider and override the GetLicense method.
How your component validates in DesignTime or Runtime it's up to you, but remember to throw an exception inside the GetLicense method when the code is not correct or the computer doesn't match the criteria or whatever your like.

For example:

Friend Class MyLicenser
     Inherits System.ComponentModel.LicenseProvider
   Public Overrides Function GetLicense(ByVal context As System.ComponentModel.LicenseContext, ByVal [type] As System.Type, ByVal instance As Object, ByVal allowExceptions As Boolean) As System.ComponentModel.License
    'Check the LicenseKey specified in step 2.
    'Returns true when the code is validated
   End Function

End Class


2. Create a public class to specify the LicenseKey to validate:
The user can change this licensekey and it is needed to validate your classes.
For example:

Public NotInheritable Class Licenser
      Private Shared mvarKey As String = String.Empty
      Public Shared Property LicenseKey() As String
                  Return mvarKey
            End Get
            Set(ByVal Value As String)
                  mvarKey = Value
            End Set
      End Property
End Class

'The implementation must be set before the user create your class, for example:
Public Sub New
      Dim control as MyUserControl
      control= New MyUserControl
End Sub

3. Implement the license to your class  
<LicenseProviderAttribute(GetType(MyLicenser))> Public NotInheritable Class MyUserControl
     Private _license As License = Nothing
     '**The license object must be validated in the constructor**
     Public Sub New()
          _license = LicenseManager.Validate(GetType(MyUserControl), Me)
          'An exception is thrown is the code is incorrect.
     End Sub

     '**The license object must be destroyed**
     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If Not _license Is Nothing Then
         _license = Nothing
      End If
     End Sub
End Class

To read more information about licensing, see:
This link include information about registry licensing, license file licensing and other methods.  You can download a sample application.
Another usefull link:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.