BUG: Project references are regenerated when you add a reference to an ActiveX control from Visual Studio .NET (820643)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

When you add a reference in Visual Studio .NET to a common language runtime proxy for the Component Object Model (COM) types that are present in an ActiveX Control type library, and then you add a reference to the corresponding ActiveX control, you notice that the common language runtime proxy is regenerated and then added as a new project reference. For example, if you already have a project reference to SHDocVw.dll, and the reference is named SHDocVw, a common language runtime proxy that is named Interop.SHDocVw.dll is created and then added as a project reference that is named SHDocVw1. You notice the same behavior when you add the previously mentioned ActiveX control from the Toolbox to a Form or to a user control.

Additionally, when you add a reference to a Windows Forms proxy for an ActiveX control, and then you add the ActiveX control from the Toolbox to a Form or to a user control, you notice that the Windows Forms proxy is regenerated and then added as a new project reference. For example, if you already have a project reference to AxSHDocVw.dll, and the reference is named AxSHDocVw, a Windows Forms proxy that is named AxInterop.SHDocVw.dll is created and then added as a project reference that is named AxSHDocVw1.

CAUSE

You add a reference in Visual Studio .NET to a common language runtime proxy or to a Windows Forms proxy. Then, you add a reference to the corresponding ActiveX control or add the ActiveX control from the Toolbox to a Form or to a user control. However, the corresponding project references already exist. The problem then occurs because Visual Studio .NET does not recognize the existing project references. Visual Studio .NET tries incorrectly to regenerate and to add these project references. This causes the behavior that is described in the "Symptoms" section.

Note You do not notice this behavior if you have a project reference to a common language runtime proxy or to a Windows Forms proxy that is created when you add a reference to an ActiveX control or when you add an ActiveX control from the Toolbox to a Form or to a user control. Such proxy files typically have file names such as Interop.SHDocVw.dll and AxInterop.SHDocVw.dll. You may also create proxies by using the .NET Framework tools such as Type Library Importer (Tlbimp.exe) and Windows Forms ActiveX Control Importer (Aximp.exe). Proxies that are created by the previously mentioned tools have file names such as SHDocVw.dll and AxSHDocVw.dll.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Run Visual Studio .NET. Move to the command prompt.
  2. From the Visual Studio .NET command prompt, change the directory path of the location of your Temp directory. You can typically find the Temp directory at the following location:

    C:\Documents and Settings\User Name\Local Settings\Temp

    Note User Name is a placeholder for your user name. Although you may use other directories as your working directory, you must not use the Documents and Settings directory if you use SHDocVw.dll. For more information about Windows Forms ActiveX Control Importer (Aximp.exe), visit the following Microsoft Web site:

    http://msdn.microsoft.com/library/en-us/cptools/html/cpgrfwindowsformsactivexcontrolimporteraximpexe.asp
  3. Run the following command from the Visual Studio .NET command prompt, and then create a common language runtime proxy (SHDocVw.dll) and a Windows Forms proxy (AxSHDocVw.dll) for the Microsoft Web Browser control:

    aximp %WINDIR%\system32\shdocvw.dll

    Note The placeholder, %WINDIR%, is the placeholder for the path of your Microsoft Windows directory.
  4. Run Visual Studio .NET.
  5. Create a Microsoft Windows application. Name this application RegenProjRefs.

    By default, Form1 is created.

    You can use either Visual Basic .NET or Visual C# .NET.
  6. On the Project menu, click Add Reference.
  7. In the Add Reference dialog box, click Browse.
  8. Locate, and then select the AxSHDocVw.dll file and the SHDocVw.dll file that you created in step 3. Click Open.
  9. Click OK to add project references for these two files to RegenProjRefs.
  10. In Visual Studio .NET 2003, click Add/Remove Toolbox Items on the Tools menu.

    In Visual Studio .NET 2002, click Customize Toolbox on the Tools menu.
  11. In the Customize Toolbox dialog box, click the COM Components tab.
  12. Click to select the Microsoft Web Browser check box, and then click OK.

    Visual Studio .NET 2003 adds Microsoft Web Browser to the Toolbox.

    Visual Studio .NET 2002 adds Explorer to the Toolbox.
  13. In Visual Studio .NET 2003, drag Microsoft Web Browser from the Toolbox to Form1.

    In Visual Studio .NET 2002, drag Explorer from the Toolbox to Form1.

    You notice the behavior that is mentioned in the "Symptoms" section.

Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbinterop kbCommandLine kbide kbCmnDlg kbMiscTools kbDeployment kbConfig kbCtrl kbControl kbForms kbWindowsForms kbbug KB820643 kbAudDeveloper