Error message: Failed to import the ActiveX control

[Deprecated]

Symptoms:

When you try dragging the control from the tool box into the form in Microsoft Visual Studio, you may receive the following error message:

Cause:

This is a bug of VS that has been reported to Microsoft. The cause of the problem is the missing of the "Interop.DYNAMICTWAINCTRLLib.dll" file or the "AxInterop.DYNAMICTWAINCTRLLib.dll" file that should be created automatically by system when you add the control to the form.

Resolution:

Method 1:

Another way to create the 2 DLL files easily:

1. Drag the Dynamic Web TWAIN control from the toolbox to the form and the "Failed to import the ActiveX control. Please ensure it is properly registered." error occurs.

2. Select "Build -> Rebuild Solution" to rebuild the project.

3. Drag the Dynamic Web TWAIN control from the toolbox to the form for the 2nd time and the "Failed to import the ActiveX control. Please ensure it is properly registered." error occurs again.

4. Select "Build -> Rebuild Solution" to rebuild the project for the 2nd time.
 
5. Drag the Dynamic Web TWAIN control from the toolbox to the form for the 3rd time and the ActiveX control will be successfully imported this time.

Method 2:

1. Manually create "Interop.DYNAMICTWAINCTRLLib.dll" and  "AxInterop.DYNAMICTWAINCTRLLib.dll" by using AxImp.exe with source code generation. You can use a command like:

AxImp /source activex_control_path_name

The following code shows the importing of the DWT ActiveX control in command line:

C:\>"C:Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\AxImp.exe" /source C:WINDOWS\system32\DynamicWebTwainCtrl.dll

And you can see the output as follows:

Generated Source: C:\AxDYNAMICWEBTWAINCTRLLib.cs
Generated Assembly: C:\DYNAMICWEBTWAINCTRLLib.dll
Generated Assembly: C:\AxDYNAMICWEBTWAINCTRLLib.dll

The "DYNAMICWEBTWAINCTRLLib.dll" file is the same as the "Interop.DYNAMICTWAINCTRLLib.dll" file while the "AxDYNAMICWEBTWAINCTRLLib.dll" is the same as the "AxInterop.DYNAMICTWAINCTRLLib.dll" file.

2. Place these two files into the subdirectory "\obj\Debug" of your project.

Is this page helpful?

Leave a Reply

Your email address will not be published.