You cannot use the Visual Studio .NET debugger or the Visual Studio 2005 debugger to debug COM components (836668)



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

In Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, when you debug a project that consumes a Microsoft Component Object Model (COM) component, you cannot use the Visual Studio .NET debugger or the Visual Studio 2005 debugger to debug the code that is contained in the COM component.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

Create a COM component

Create a COM component by using Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. To do this, follow these steps:
  1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
  3. Under Project Types, click Visual C++ Projects, and then under Templates, click ATL Project.

    Note In Visual Studio 2005, click Visual C++.
  4. Type MyCom in the Name box, and then click OK. The ATL COM AppWizard dialog box appears.
  5. Click Finish.
  6. In Solution Explorer, right-click MyCom, point to Add, and then click Add Class. The Add Class - MyCom dialog box appears.
  7. Click ATL Control under Templates, and then click Open. The ATL Control Wizard - MyCom dialog box appears.
  8. Type TestClass in the Short Name box, and then click Finish.
  9. On the View menu, click Class View.
  10. In Class View, right-click ITestClass, point to Add, and then click Add Method. The Add Method Wizard - MyCom dialog box appears.
  11. Type TestMethod in the Method name box, and then click Finish.
  12. Add the following code in the TestMethod method:
    ::MessageBox(NULL, "Hello World", "Msg", 0);
    
  13. On the Build menu, click Build Solution to build the project.

Create a client project

Create a client project by using Microsoft Visual Studio .NET 2003 or Visual Studio 2005. To do this, follow these steps:
  1. In Visual Studio .NET 2003 or Visual Studio 2005, point to New on the File menu, and then click Project.
  2. Under Project Types, click Visual Basic Projects, and then under Templates, click Console Application .
    Note In Visual Studio 2005, click Visual Basic.
  3. Type MyApplication in the Name box, and then click OK.
  4. In Solution Explorer, right-click References, and then click Add Reference.
  5. Click the COM tab, and then click Browse to locate and to select the MyCom.dll file.
  6. Click OK to close the Add Reference dialog box.
  7. Add the following line of code at the top of the Module1.vb file:
    Imports MYCOM
  8. In the Main method, add the following code:
    Dim objTestClass as new CTestClassClass
    ' Set the break point at this line of the code.
    objTestClass.TestMethod()
  9. Select the following line of code, and then press F9.
    objTestClass.TestMethod()
  10. On the Debug menu, click Start. The execution stops at the break point that was set in the step 9.
  11. Press F11 to debug the method of the COM component. You will notice that you cannot debug the method of the COM component.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:2/28/2006
Keywords:kbvs2005swept kbvs2005applies kbprb kbDLL kbCOMInterop kbAppWizard kbACL kb3rdparty kbDebug kbConsole kbinfo KB836668 kbAudDeveloper