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:
- Question: How can I add ActiveX controls requiring run-time licenses in Visual Basic 2005 or in Visual Basic .NET?
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:
- Click Start > All Programs > Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET
- From the file menu, point your cursor to "New," and click "Project."
- Click the "Visual Basic Projects" under the "Project Types" from the "New Project" dialog box. Click "Windows Application" under "Templates," and click "OK."
- Click Start > All Programs > Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET > Visual Studio 2005 Command Prompt or Visual Studio .NET Command Prompt
- 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"
- Click "Add Reference" from the "Project Menu."
- Click "Browse" and choose the newly created ActiveX Control Interop assemblies.
- Add both "MyProject.dll" and "AxMyProject.dll." Adding these two files allows them to be copied locally.
- Add one Button control in the form.
- Double click on the button to get the code needed for the Button Click Event method.
- 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()
- Determine and take note of the run-time license key for the ActiveX control. This is usually "gnvlslnjskvlmlgnnimh".
- 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")"
- Add the ActiveX control to the control collection of the form and show the control. To do this, the following codes may be used:
Answer: You can access the error descriptions via the ResultString property of the ActiveX control.
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.