How to debug a COM+ component by using Visual Studio 2005 or by using Visual Studio .NET

Article translations Article translations
Article ID: 919519 - View products that this article applies to.
Expand all | Collapse all

On This Page

SUMMARY

This article describes how to debug a COM+ component by using Microsoft Visual Studio 2005 or by using Microsoft Visual Studio .NET. Additionally, this article describes how to debug a COM+ component that is installed on the same computer as the client application and how to debug a COM+ component that is installed on a remote computer.

INTRODUCTION

This article describes how to debug a COM+ component by using Visual Studio 2005 or by using Visual Studio .NET. You can use a COM+ component in the following environments:
  • You can use a COM+ component that is installed on the same computer as the client application. This is a local COM+ component.
  • You can use a COM+ component that is installed on a different computer from the client application. This is a remote COM+ component.
Additionally, a COM+ component can use unmanaged code or managed (Microsoft .NET) code. This article includes the steps to debug all these types of COM+ components.

MORE INFORMATION

How to debug a local COM+ component

A local COM+ component is installed on the same computer as the client application. To debug a local COM+ component, use the following procedures.

Prerequisites

Before you try to debug a local COM+ component, make sure that you have the following items:
  • A COM+ application installed on the local computer
  • A COM+ component (DLL) installed in the COM+ application

    Note You must build the DLL in debug mode before you add the DLL to the COM+ application.
  • The source files for the COM+ component

    Note The source files must match the running build of the COM+ component.
  • The symbolic debugging information for the COM+ component

    Note The symbolic debugging information is contained in the .pdb file for the project.
  • A client application that creates an instance of the local COM+ component and that calls a method or a property of the local COM+ component
  • The source files for the client application
  • The symbolic debugging information for the client application

    Note The symbolic debugging information is contained in the .pdb file for the project.

Set up the debugging files

Copy the source files and the symbolic debugging information (the .pdb file) for the COM+ component into the same folder. Therefore, the files will be easier to locate when you set up the Visual Studio environment.

Set up the Visual Studio environment

  1. Start Visual Studio 2005, or start Visual Studio .NET.
  2. In Visual Studio 2005, point to Open on the File menu, and then click Project/Solution.

    In Visual Studio .NET, point to Open on the File menu, and then click Project.
  3. Locate the project that contains the client application, and then click Open.
  4. In Solution Explorer, right-click the solution, and then click Properties.
  5. Expand Common Properties, and then click Debug Source Files.
  6. Click New Line.
  7. Click the ellipsis button (...).
  8. Locate the directory where the source files for the COM+ component are located, and then click Open.
  9. Set up the debug symbol files for the COM+ component. To do this in Visual Studio 2005, follow these steps:
    1. In the Solution Property Pages dialog box, click OK.
    2. On the Tools menu, click Options.
    3. Expand Debugging, and then click Symbols.
    4. Click New Line.
    5. Type the path of the folder where the .pdb file for the COM+ component is located, and then click OK.
    To do this in Visual Studio .NET, follow these steps:
    1. In the Solution Property Pages dialog box, click Debug Symbol Files.
    2. Click New Line.
    3. Click the ellipsis button (...).
    4. Locate the folder where the .pdb file for the COM+ component is located, and then click Open.
    5. Click OK.
  10. Add a breakpoint in the client application code where you create an instance of the local COM+ component.
  11. On the File menu, point to Open, and then click File.
  12. Locate the source files for the COM+ component, and then click Open.
  13. Add a breakpoint in the COM+ component source code where you want the Visual Studio debugger to stop.

Debug the local COM+ component

  1. Start the Visual Studio debugger. To do this in Visual Studio 2005, click Start Debugging on the Debug menu.

    To do this in Visual Studio .NET, click Start on the Debug menu.
  2. When the Visual Studio debugger reaches the breakpoint in the client application, step into the code. To do this, click Step Into on the Debug menu.
  3. When the instance of the COM+ component is created, attach to the Dllhost.exe process. To do this in Visual Studio 2005, follow these steps:
    1. On the Debug menu, click Attach to Process.
    2. Click Dllhost.exe, and then click Attach.
    To do this in Visual Studio .NET, follow these steps:
    1. On the Debug menu, click Processes.
    2. Click Dllhost.exe, and then click Attach.
  4. In Visual Studio .NET, select the type of code to debug by using one of the following methods:
    • If the COM+ component uses unmanaged code, click to select the Native check box, click OK, and then click Close.
    • If the COM+ component uses managed code, click to select the Common Language Runtime check box, click OK, and then click Close.
    Note This step is not required in Visual Studio 2005. Visual Studio 2005 automatically determines the type of code to debug.
  5. On the Debug menu, click Continue.

    Notice that the Visual Studio debugger reaches the breakpoint that you set in the COM+ component source code.
  6. On the Debug menu, click Continue.

    When the Visual Studio debugger leaves the COM+ function, you receive the following message:
    No symbols are loaded for any call stack frame. The source code cannot be displayed.
  7. Click OK.
  8. On the Debug menu, click Continue.

    The Visual Studio debugger reaches the end of the client application code, and the Visual Studio debugger stops running.
  9. On the Debug menu, click Detach All.

How to debug a remote COM+ component

A remote COM+ component is installed on a different computer from the client application. When you debug a remote COM+ component, you must run the following instances of the Visual Studio debugger:
  • An instance of the Visual Studio debugger for the client application
  • An instance of the Visual Studio debugger for the remote COM+ component

    Note This instance of Visual Studio attaches to the Dllhost.exe process that is running on the remote computer.
To debug a remote COM+ component, use the following procedures.

Prerequisites

Before you try to debug a remote COM+ component, make sure that you have the following items:
  • A COM+ application installed on the remote computer
  • A COM+ component (DLL) installed in the COM+ application

    Note You must build the DLL in debug mode before you add the DLL to the COM+ application.
  • The source files for the COM+ component

    Note The source files must match the running build of the COM+ component.
  • The symbolic debugging information for the COM+ component

    Note The symbolic debugging information is contained in the .pdb file for the project.
  • The correct remote debugging setup

    Note This includes the correct security settings on the remote computer that is hosting the COM+ component. For more information about how to set up remote debugging, visit the following Microsoft Developer Network (MSDN) Web site:
    http://msdn2.microsoft.com/en-us/library/y7f5zaaa(vs.71).aspx
  • A client application that creates an instance of the remote COM+ component and that calls a method or a property of the remote COM+ component
  • The source files for the client application
  • The symbolic debugging information for the client application

    Note The symbolic debugging information is contained in the .pdb file for the project.

Set up the debugging files

On the remote computer, copy the symbolic debugging information (the .pdb file) for the COM+ component into the same folder where the DLL is located.

Start an instance of the Visual Studio debugger for the client application

  1. Start Visual Studio 2005, or start Visual Studio .NET.
  2. In Visual Studio 2005, point to Open on the File menu, and then click Project/Solution.

    In Visual Studio .NET, point to Open on the File menu, and then click Project.
  3. Locate the project that contains the client application, and then click Open.
  4. Add a breakpoint in the client application code where you call a method or a property of the remote COM+ component.
  5. Start the Visual Studio debugger. To do this in Visual Studio 2005, click Start Debugging on the Debug menu.

    To do this in Visual Studio .NET, click Start on the Debug menu.

    Note The Visual Studio debugger stops at the breakpoint that you added in step 4.

Start an instance of the Visual Studio debugger for the remote COM+ component

  1. Start Visual Studio 2005, or start Visual Studio .NET.
  2. Attach to the Dllhost.exe process. To do this in Visual Studio 2005, follow these steps:
    1. On the Tools menu, click Attach to Process.
    2. In the Qualifier box, type the name of the remote computer where the COM+ component is installed.
    3. Click Refresh.
    4. Click Dllhost.exe, and then click Attach.
    To do this in Visual Studio .NET, follow these steps:
    1. On the Tools menu, click Debug Processes.
    2. In the Name box, type the name of the remote computer where the COM+ component is installed.
    3. Click Refresh.
    4. Click Dllhost.exe, and then click Attach.
  3. In Visual Studio .NET, select the type of code to debug by using one of the following methods:
    • If the COM+ component uses unmanaged code, click to select the Native check box, click OK, and then click Close.
    • If the COM+ component uses managed code, click to select the Common Language Runtime check box, click OK, and then click Close.
    Note This step is not required in Visual Studio 2005. Visual Studio 2005 automatically determines the type of code to debug.
  4. Set up the debug symbol files for the COM+ component. To do this in Visual Studio 2005, follow these steps:
    1. On the Tools menu, click Options.
    2. Expand Debugging, and then click Symbols.
    3. Click New Line.
    4. Type the path of the folder on the remote computer where the .pdb file for the COM+ component is located, and then click OK.
    To do this in Visual Studio .NET, follow these steps:
    1. In Solution Explorer, right-click the solution, and then click Properties.
    2. Expand Common Properties, and then click the Debug Symbol Files tab.
    3. Click New Line.
    4. Click the ellipsis button (...).
    5. Type the path of the folder on the remote computer where the .pdb file for the COM+ component is located, and then click OK.
  5. On the Debug menu, click Break All.
  6. On the Debug menu, point to Windows, and then click Modules.
  7. In the list, locate the DLL for the COM+ component.
  8. In Visual Studio 2005, confirm that the Symbol Status column displays Symbols loaded.

    In Visual Studio .NET, confirm that the Information column displays Symbols loaded.

    Note If the Symbol Status column or the Information column displays No symbols loaded, right-click the DLL for the COM+ component, and then click Load Symbols. If you are prompted for the path of the symbols, locate the folder on the remote computer where the .pdb file is located, and then click Open.
  9. On the Debug menu, click Continue.
  10. On the File menu, point to Open, and then click File.
  11. Locate the source files for the COM+ component, and then click Open.
  12. Add a breakpoint in the COM+ component source code where you want the Visual Studio debugger to stop.

Debug the remote COM+ component

  1. Switch to the instance of the Visual Studio debugger for the client application.
  2. On the Debug menu, click Continue.
  3. Switch to the instance of the Visual Studio debugger for the remote COM+ component.

    Notice that the Visual Studio debugger reaches the breakpoint that you set in the COM+ component source code.

REFERENCES

For more information about how to use the Visual Studio debugger, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/library/k0k771bt(vs.71).aspx
For more information about how to specify Visual Studio debugger settings, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/library/28ydy176(vs.71).aspx

Properties

Article ID: 919519 - Last Review: November 22, 2007 - Revision: 1.4
APPLIES TO
  • Microsoft Visual Studio 2005 Team System Architect Edition
  • Microsoft Visual Studio 2005 Team System Developer Edition
  • Microsoft Visual Studio 2005 Team System Test Edition
  • Microsoft Visual Studio 2005 Team Foundation
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional 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
Keywords: 
kbhowto kbinfo KB919519

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com