The ActiveX user control is not visible in the Form Designer when you reopen an existing project (818220)
The information in this article applies to:
- Microsoft .NET Framework 1.1
- Microsoft .NET Framework 1.0
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
- Microsoft .NET Framework 2.0
SYMPTOMSWhen you reopen an existing Windows application in Visual
Studio .NET or Visual Studio 2005, a previously visible ActiveX user control may not be visible in
the Windows Form Designer. Also, when you try to compile the project, you may
receive errors similar to the following: Type
'AxProject1.AxTestControl' is not defined. The
referenced component 'AxProject1' could not be found. A .NET assembly wrapper
for the dependent type library 'Project1' could not be
found. CAUSEWhen you add an ActiveX user control to a Visual Studio .NET or Visual Studio 2005
project, Visual Studio .NET or Visual Studio 2005 internally starts the Windows Forms ActiveX Control
Importer tool (Aximp.exe). Aximp.exe converts the type library of the ActiveX
user control, and it generates the following two files:
- A common language runtime proxy for COM types.
- A Windows Forms proxy for the ActiveX user
control.
These two proxy files have information that relates to the
existing ActiveX user control. When you add a public member to the
existing ActiveX user control, such as an event, method, or property, and then
you recompile the ActiveX user control, one or more public members are added to
the interface of the ActiveX user control. However, the common language runtime
proxy file is not updated with this new information. Therefore, the ActiveX
user control is not generated correctly in the Windows Form Designer, the
corresponding Windows Forms proxy is not updated either, and the behavior
discussed in the "Symptoms" section of this article occurs. Note On the Properties dialog box of the project, you
can click the Component tab, and then select the
Binary Compatibility option before you recompile the existing
ActiveX user control in Microsoft Visual Basic 6.0. In this case, although the
common language runtime proxy is updated, the Windows Forms proxy is not
updated. This results in the same symptoms. WORKAROUNDTo work around this problem, remove the existing references
of the ActiveX user control, and then add the updated references again. To do
this, follow one of the following methods. Method 1- In Solution Explorer, under References,
right-click AxProject1, and then click
Remove.
- Under References, right-click
Project1, and then click Remove.
- In the toolbox, double-click
Project1.TestControl to add the modified ActiveX user control
to the form.
Notice that the ActiveX user control in the Windows Form
Designer and the references to AxProject1 and
Project1 appear under References for UserControlDemo. - On the Build menu, click Build
Solution.
You do not receive any errors. Note If you use this workaround, the modified ActiveX user control is
added to your form as AxTestControl2, and your form still has some code that relates to AxTestControl1. For example, the following statement is still present, even
though AxTestControl1 is no longer on your form: Visual Basic .NET Sample CodeFriend WithEvents AxTestControl1 As AxProject1.AxTestControl Visual C# .NET Sample Codeprivate AxProject1.AxTestControl axTestControl1; If you used AxTestControl1 elsewhere in your code, and
you did not explicitly create an instance of an
AxProject1.AxTestControl object, you may receive a
'NullReferenceException'
error. Moreover, if you have multiple forms with an instance of the
ActiveX user control, you must repeat the previous steps for each form. Method 2- In Solution Explorer, under References,
right-click AxProject1, and then click
Remove.
- Under References, right-click
Project1, and then click Remove.
- Open the Visual Studio .NET or Visual Studio 2005 command prompt, and then change
the directory path to the bin directory of
UserControlDemo.
- Type the following command, and then press the ENTER key to
run Aximp.exe to explicitly generate a common language runtime proxy and a
Windows Forms proxy:
aximp
"<FilePath>\Project1.ocx"
/out:AxInterop.Project1.dll
AxInterop.Project1.dll and
Project1.dll are generated in the bin directory.
Note Replace FilePath with the path of the
directory that contains Project1.ocx. - Switch to Visual Studio .NET or Visual Studio 2005. On the
Project menu, click Add Reference.
- In the Add Reference dialog box that
appears, click Browse.
- Locate AxInterop.Project1.dll and Project1.dll, and then
select them.
- Click Open, and then click
OK to add these references to your project.
- Close and reopen the Windows Form Designer.
Notice the modified ActiveX user control in the Windows Form
Designer.
Note Unlike in the previous workaround, the modified ActiveX user
control is still named AxTestControl1. Therefore, there is no unnecessary code. - On the Build menu, click Build
Solution.
You do not receive any errors. Note These steps are based on the sample from the "More Information"
section. Therefore, the entities mentioned in these tasks may differ from the
entities in your project, depending on your implementation. STATUS This
behavior is by design.REFERENCES For additional information, click the following article
number to view the article in the Microsoft Knowledge Base: For more information, visit the following MSDN Web
Sites:
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbIDEProject kbide kbComCtrls kbCtrlCreate kbCtrl kbControl kbCOMInterop kbprb KB818220 kbAudDeveloper |
---|
|