Common ActiveX Questions and Solutions

ActiveX was developed by Microsoft to allow the sharing of information among various operations. However, since some computers don't have it automatically installed, some can problems occur, which lead to some users asking questions about ActiveX. To help you with it, here are some common ActiveX questions and their corresponding solutions:

  1. Question: How can I add ActiveX controls requiring run-time licenses in Visual Basic 2005 or in Visual Basic .NET?
  2. Answer: In Visual Basic 2005 or in Visual Basic .NET, the licenses collection does not exist. You must first embed or enter the license information into the control. Here’s how:

    • Creating a New Visual Basic 2005 or Visual Basic .NET Project:
      1. Click Start > All Programs > Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET
      2. From the file menu, point your cursor to "New," and click "Project."
      3. Click the "Visual Basic Projects" under the "Project Types" from the "New Project" dialog box. Click "Windows Application" under "Templates," and click "OK."
    • Creating ActiveX Interop Assemblies:
      1. Click Start > All Programs > Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET > Visual Studio 2005 Command Prompt or Visual Studio .NET Command Prompt
      2. To create the two assemblies that you need, type the following in the command box:
        "aximp /out:C:\temp\AxMyProject.dll ""C:\Windows\System32\MyProject.ocx"
    • Creating the Control Dynamically
      1. Click "Add Reference" from the "Project Menu."
      2. Click "Browse" and choose the newly created ActiveX Control Interop assemblies.
      3. Add both "MyProject.dll" and "AxMyProject.dll." Adding these two files allows them to be copied locally.
      4. Add one Button control in the form.
      5. Double click on the button to get the code needed for the Button Click Event method.
      6. Paste the code into the Button Click Event method to create a new instance of ActiveX control through the AxHost.

      Having ActiveX problems? Use this ActiveX test tool to fix your issues.

      Dim myControl As New AxMyProject.AxMyLicensedControl()

    • Adding the License to the ActiveX Control
      1. Determine and take note of the run-time license key for the ActiveX control. This is usually "gnvlslnjskvlmlgnnimh".
      2. Paste the following code below the "Dim myControl As New AxMyProject.AxMyLicensedControl()" under the Button Click Event method:

        • "Dim f As System.Reflection.FieldInfo"
        • "f = GetType(AxHost).GetField("licenseKey", _"
        • "Reflection.BindingFlags.NonPublic _"
        • "Or Reflection.BindingFlags.Instance)"
        • "f.SetValue(myControl, "gnvlslnjskvlmlgnnimh")"
    • Adding the ActiveX Control to the Form
      1. Add the ActiveX control to the control collection of the form and show the control. To do this, the following codes may be used:

        • "myControl.Show()"
        • "Controls.Add(myControl)"
      2. Run the project by pressing F5
      3. Add the ActiveX Control to the form by clicking the button

  3. Question: Where can I find the description for the error codes which were returned by the ActiveX control?
  4. Answer: You can access the error descriptions via the ResultString property of the ActiveX control.

  5. Question: How can I use a single ActiveX control to read or write non-contagious data areas in the sequential transactions?
  6. Answer: If your Operating System supports synchronous operation, you can create sequential SyncRefresh calls in order to read non-contiguous areas. However, if it doesn't, you can try upgrading your system so that it supports the synchronous operation.

Windows and the Windows logo are trademarks of the Microsoft group of companies.
Microsoft is a registered trademark of Microsoft Corporation in the United States and/or other countries.