Microsoft KB Archive/821631

= Visual Studio .NET or Visual Studio 2005 cannot add a reference to an executable assembly =

Article ID: 821631

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * 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

-



SYMPTOMS
When you add a reference to an executable assembly by using the Visual Studio .NET or Visual Studio 2005 IDE, you receive the following error message:

A reference to ' .exe' could not be added. This is not a valid assembly or COM component. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that it is a valid assembly or COM component.



WORKAROUND
To work around this problem, add the reference to the executable assembly by using the command-line compiler. To do this, follow these steps:  On the View menu in Visual Studio .NET or in Visual Studio 2005, point to Other Windows, and then click Command Window. At the command prompt, change the directory to C:\ConsoleApp1 . Type the following command at the command prompt, and then press ENTER:

vbc module1.vb /r:c:\WinApp1\Bin\WinApp1.exe

Notice that Module1.exe builds successfully.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior

 * 1) Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
 * 2) On the File menu, click New, and then click Project.
 * 3) Under Project types, click Visual Basic Projects, and then click Windows Application under Templates.

Note In Visual Studio 2005, click Visual Basic under Project types.
 * 1) Name the project WinApp1, type C:\ for the Location, and then click OK. By default, Form1 is created.
 * 2) On the Build menu, click Build Solution. WinApp1.exe is created.
 * 3) On the File menu, click New, and then click Project.
 * 4) Under Project types, click Visual Basic Projects, and then click Console Application under Templates.

Note In Visual Studio 2005, click Visual Basic under Project types.
 * 1) Name the project ConsoleApp1, and then click OK. By default, Module1.vb is created.
 * 2) On the View menu, click Solution Explorer to open Solution Explorer.
 * 3) In Solution Explorer, right-click References, and then click Add References.
 * 4) In the Add Reference dialog box, click the .NET tab.
 * 5) Click Browse, and then locate C:\WinApp1\bin\WinApp1.exe. Click Open, and then click OK.

Note In Visual Studio 2005, you do not have to click Open.

