Visual Studio .NET or Visual Studio 2005 cannot add a reference to an executable assembly (821631)



The information in this article 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 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

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 'assemblyname.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:
  1. On the View menu in Visual Studio .NET or in Visual Studio 2005, point to Other Windows, and then click Command Window.
  2. At the command prompt, change the directory to C:\ConsoleApp1.
  3. 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.

MORE INFORMATION

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.
  4. Name the project WinApp1, type C:\ for the Location, and then click OK. By default, Form1 is created.
  5. On the Build menu, click Build Solution. WinApp1.exe is created.
  6. On the File menu, click New, and then click Project.
  7. 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.
  8. Name the project ConsoleApp1, and then click OK. By default, Module1.vb is created.
  9. On the View menu, click Solution Explorer to open Solution Explorer.
  10. In Solution Explorer, right-click References, and then click Add References.
  11. In the Add Reference dialog box, click the .NET tab.
  12. 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.

REFERENCES

For more information about how to add or remove references by using Visual Studio .NET, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:3/6/2006
Keywords:kbvs2005swept kbvs2005applies kbCompiler kbDLL kberrmsg kbprb KB821631 kbAudDeveloper