Microsoft KB Archive/820643

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

Article ID: 820643

Article Last Modified on 6/1/2007

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-





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 &quot;Symptoms&quot; 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.



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\ \Local Settings\Temp

Note  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://msdn2.microsoft.com/en-us/library/8ccdh774(vs.71).aspx
 * 1) 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 \system32\shdocvw.dll

Note The placeholder,, is the placeholder for the path of your Microsoft Windows directory.
 * 1) Run Visual Studio .NET.
 * 2) 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.
 * 1) On the Project menu, click Add Reference.
 * 2) In the Add Reference dialog box, click Browse.
 * 3) Locate, and then select the AxSHDocVw.dll file and the SHDocVw.dll file that you created in step 3. Click Open.
 * 4) Click OK to add project references for these two files to RegenProjRefs.
 * 5) 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.
 * 1) In the Customize Toolbox dialog box, click the COM Components tab.
 * 2) 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.
 * 1) 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 &quot;Symptoms&quot; section.

