PRB: Cannot Add ActiveX Control to Toolbox (320780)
The information in this article applies to:
- Microsoft Visual C# .NET (2002)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual J# .NET (2002)
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
fully qualified path to the Ax wrapper dll 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
Modification Type: | Major | Last Reviewed: | 8/7/2003 |
---|
Keywords: | kbdocerr kbprb KB320780 |
---|
|