Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Creating Secure Trial Versions for .NET Applications - A Tutorial

, 16 Oct 2012 CPOL
Implement trial licensing model for your .NET applications with minimal costs
Imports SoftActivate.Licensing

Public Class ActivationForm
    Public Sub New(ByVal actionText As String, ByVal licenseKey As String)
        actionLabel.Text = actionText
        Me.licenseKey = licenseKey
    End Sub

    Public Sub ActivateLicense()
        _isActivated = False
        licensingClient = New LicensingClient("http://localhost:55355/", CreateLicenseKeyTemplate(), licenseKey, Nothing, 12345)

    End Sub

    Private Sub OnLicensingComplete() Handles licensingClient.OnLicensingComplete
        _activationKey = licensingClient.ActivationKey
        _hardwareId = licensingClient.HardwareId
        _licenseExpirationDate = licensingClient.LicenseExpirationDate
        _isActivated = True
        Invoke(New LicensingCompleteEventHandler(AddressOf OnLicensingCompleteUI))
    End Sub

    Private Sub OnLicensingCompleteUI()
    End Sub

    Private Sub OnLicensingException(ex As Exception) Handles licensingClient.OnLicensingException
        _isActivated = False
        Invoke(New LicensingExceptionEventHandler(AddressOf OnLicensingExceptionUI), ex)
    End Sub

    Private Sub OnLicensingExceptionUI(ex As Exception)
        MessageBox.Show("Error: " + ex.Message)
    End Sub

    ReadOnly Property ActivationKey As String
            Return _activationKey
        End Get
    End Property

    ReadOnly Property HardwareId As String
            Return _hardwareId
        End Get
    End Property

    ReadOnly Property LicenseExpirationDate As String
            Return _licenseExpirationDate
        End Get
    End Property

    ReadOnly Property IsActivated As Boolean
            Return _isActivated
        End Get
    End Property

    Private Function CreateLicenseKeyTemplate() As KeyTemplate
        Return New KeyTemplate(5, 5, "doxzyMNu7n46whM=", Nothing, 109, 16, "ProductId")
    End Function

    Private WithEvents licensingClient As LicensingClient
    Private licenseKey As String
    Private _activationKey As String
    Private _hardwareId As String
    Private _licenseExpirationDate As DateTime
    Private _isActivated As Boolean
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ansel Reynard

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 16 Oct 2012
Article Copyright 2012 by Ansel Reynard
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid