Microsoft KB Archive/320780

= PRB: Cannot Add ActiveX Control to Toolbox =

Article ID: 320780

Article Last Modified on 8/7/2003

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual J# .NET 2003 Standard Edition

-



This article was previously published under Q320780



SYMPTOMS
After you use Aximp.exe to wrap an ActiveX control, you may receive the following error message when you try to add the Ax wrapper to the .NET Framework Components tab in the Customize Toolbox dialog box:

There are no components in  that can be placed on the toolbox.



CAUSE
By default, the ToolboxItem attribute is set to False in the generated Ax wrapper. A False value for this attribute prevents the control or wrapper from being added to the Toolbox.



RESOLUTION
There are two resolutions to this problem:  Import the Control by Using the Development Environment

The easiest way to avoid this problem is to add the ActiveX control to the Toolbox from the COM Components tab instead of by running Aximp.exe and using the .NET Framework Components tab in the Customize Toolbox dialog box. The development environment generates the wrappers that you need when you add the control through the COM Components dialog box. Manually Change the Attribute Value  NOTE: All of the file names in the commands in step 1 and step 3 must be fully qualified path names.

  Run Aximp.exe with the /source switch to generate the Visual C# code for the Ax wrapper for the specified ActiveX control. The file generates the source file, an interop assembly, and an Ax wrapper assembly for the specified control. For example, the following command generates the Visual C# source code (Axmscomdlg.cs) for the Ax wrapper for the Microsoft Common Dialog Control: aximp comdlg32.ocx /out:AxMSComDlg.dll /source   Open the Visual C# source file in a text editor such as Notepad, insert the following attribute statement, and then save the .cs source file: [System.ComponentModel.ToolboxItemAttribute(true)] NOTE: Make sure that you insert the statement after the namespace and before the class definition.

  Use the following command to compile the .cs file:

NOTE: Make sure that you reference the runtime callable wrapper (RCW) assembly: csc /t:library /r:MSComDlg.dll /out:AxMSComDlg.dll AxMSComDlg.cs                       </li></ol> </li></ul>

<div class="moreinformation_section">

MORE INFORMATION
Aximp.exe converts a whole ActiveX Control type library at one time and produces a set of assemblies that contain the Common Language Runtime meta data and control implementation for the types that are defined in the original type library. The generated files are named according to the following pattern:
 * Common Language Runtime proxy for COM types: .dll
 * Windows Forms proxy for ActiveX controls (where Ax signifies ActiveX): Ax .dll

For the control that is used as an example in this article (Comdlg32.ocx), the files that are created are Mscomdlg.dll and Axmscomdlg.dll.)

Steps to Reproduce the Problem
This problem can be reproduced by using any ActiveX control. The Microsoft Common Dialog Control (Comdlg32.ocx) is used in this example. <ol>  Execute the following command from a Visual Studio .NET command prompt: aximp comdlg32.ocx /out:AxMSComDlg.dll /source NOTE: This command generates the Ax wrapper (Axmscomdlg.dll), the RCW (Mscomdlg.dll), a program database file (Axmscomdlg.pdb), and the Visual C# source file (Axmscomdlg.cs) for the Ax wrapper.

</li> Start a new Visual Basic or Visual C# Windows Application project. By default, Form1 is created.</li> On the Tools menu, click Customize Toolbox.</li> Click the .NET Framework Components tab.</li> Click Browse, and then locate the folder that contains the Ax wrapper that was generated in step 1.</li> Click to select Axmscomdlg.dll, and then click Open. You receive the error message that is described in the &quot;Symptoms&quot; section.</li></ol>

Keywords: kbprb kbdocerr KB320780

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.