“Runtime Error '429': You do not have an appropriate license to use this functionality”


 

PROBLEM: An error reporting "a license is required to use this functionality" occurs when an application containing an instance of a DBI component, created exclusively through code, is distributed to a client machine.

 

CAUSE: Runtime licensing of ActiveX components instantiated in an application through code at runtime (the component is not included in the project at design time).  The licenses collection cannot locate the licensing information.

 

APPLIES TO: Commercially licensed ActiveX components and User control ActiveX components containing commercial licensed ActiveX components (please see special notes at the end).

 

DETAIL: Developers distributing applications that create an instance of a commercial licensed ActiveX component or an ActiveX component created in VB 6 containing a commercial licensed component receive the following error when the application is run on a client machine:

 

“Runtime Error '429': You do not have an appropriate license to use this functionality”

 

The error is the result of missing license information in the licenses collection of the application.

 

RESOLUTION: In order to create an instance of a commercial licensed component or an ActiveX component containing a commercial licensed ActiveX component, the license for the component must first be added to the licenses collection of the application.  

 

Typically, the license for a component is added to the licenses collection for the application when the component is added to the toolbar of the project (Visual Basic).  If however an application only creates instances of a component in code, not having added the component the toolbar prior to compiling the application, then the license must be manually added in code prior to creating the instance of the component.  To accomplish this the developer must first store the license in a text file, which ultimately must be distributed with the application.

 

The following Visual Basic code illustrates how to capture the license string for a component called ctDBI, and store it in a text file:

 

Dim intFile As Integer

intFile = FreeFile

' Open a file to write the license key to.

Open "c:\Ctl_DBI.txt" For Output As #intFile

Dim strLicense As String

strLicense = Licenses.Add("ctDBI.ctDBICtrl.1")

' Note: ctDBI.ctDBICtrl.1is the Prog ID for the component as stored in the registry

' The Licenses.Add method returns the license key string for the component

' Write the license key to the file.

Write #intFile, strLicense

Close #intFile

 

The Ctl_DBI.txt file now contains the license key string for the ctDBI ActiveX component.  

 

NOTE: This must be run on the machine licensed to develop with component and should be run independently of the application project in which the component is to be used.

 

Once the license text file has been generated the code to add the license to the application's license collection can be added.  

 

NOTE: This code must be executed prior to creating the instance of the component.

 

intFile = FreeFile

Open "c:\ctl_DDB.txt" For Input As #intFile

Dim strKey As String

' On the client machine, read the license key from the file.

Input #intFile, strKey

'Add the license for the component to the licenses collection for the application

Licenses.Add "ctDBI.ctDBICtrl.1", strKey

Close #intFile

 

Once the license has been added to the licenses collection of the application, the component can be instantiated and used, as follows:

 

'Create the instance of the component

Set extObj = Controls.Add("ctDBI.ctDBICtrl.1", "ctl1")

'Note: ctDBI.ctDBICtrl.1 is the Prog ID of the component as stored in the registry

'Make the object visible

With Controls("ctl1")

.Visible = True

End With

 

SPECIAL NOTE For User-created Controls:

If the component being instantiated is a user control containing a commercial licensed ActiveX component, the user control must be generated with a license.  In Visual Basic this will generate a .vbl file.  Once the user control ocx has been generated and registered, the license for the user control can be added to the application in the same manner as described above.