Bridges > COM Export Bridge > Examples > Debugging COM Wrapper Objects

# Debugging COM Wrapper Objects

When running an application that relies on a COM wrapper object, it is often difficult to determine when errors occur in the associated IDL object or IDL process. Since the instance of the wrapper object is invoked outside of IDL, the normal debugging capabilities of the IDL Workbench are not available.

However, it is possible to obtain this output by setting the IDL_BRIDGE_DEBUG environment variable as described in “IDL_BRIDGE_DEBUG” (Chapter 1, Using IDL). This debug information is usually written to stdout on Unix and Windows (unless noted otherwise in the following table). This output can also be captured in Visual Studio, the Debug Monitor (DBMON.exe) or WinDbg debugger on Windows. In each instance, the output depends on the value of the IDL_BRIDGE_DEBUG environment variable:

Value | Behavior
--- | ---
0 | Turn off debug output
1 | Turn on debug output, which includes output from library load errors, IDL execution errors, and PRINT statement output

The expected behavior in common debugging environments is described in the following table.

Application | Debug Output
--- | ---
Console Application | Command window — debug information is presented in line with any console window output when an .exe is executed from the Windows command window
Visual Studio — debug output does not appear
DBMON — debug information appears in the debug monitor window as it is generated
Windows Application | Command window — no debug output since the window that is launched has no knowledge of the debugging environment variable
Visual Studio — debug output appears in the Debug Output window only when the application window is closed
DBMON — debug information appears in the debug monitor window as it is generated

Note: In Windows, the environment variable is read when an application or command window is initially instantiated. For example, if you open Visual Studio and then change the value of the environment variable, you must re-launch Visual Studio to see the change in debug output behavior. DBMON is an exception as it always listens for debug information output and immediately reflects changes in content level