Platform SDK: Transaction Server |
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
Using Visual Basic 6.0
Microsoft Transaction Server components written in Microsoft® Visual Basic® version 6.0 can be debugged directly in the Visual Basic Integrated Development Environment (IDE).
The following steps describing how to debug a Visual Basic COM component do not apply to Visual Basic version 6.0 or later.
For more information about debugging MTS components using Visual Basic version 6.0, see the Visual Basic version 6.0 documentation.
Using Visual Basic 5.0
Microsoft Transaction Server components written in Microsoft® Visual Basic® version 5.0 or Visual C++® version 5.0 can be debugged in the Microsoft Visual Studio™ 97 Integrated Development Environment (IDE).
If you want to debug your components after they are compiled, you cannot use the Visual Basic 5.0 debugger, which only debugs at design time. To debug a compiled Visual Basic component, you will need to use the functionality of the Visual Studio 97 debugger.
Follow these steps to configure Visual Studio to debug MTS components built with Visual Basic 5.0:
To facilitate application debugging using Visual Basic 5.0, a component that uses ObjectContext can be debugged by enabling a special version of the object context. This debug-only version is enabled by creating the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Transaction Server\Debug\RunWithoutContext
Note that when running in debug mode, none of the functionality of MTS is enabled. GetObjectContext will return the debug ObjectContext rather than returning Nothing.
When running in this debug mode, the ObjectContext operates as follows:
You can also develop your own testing message box functions to generate an assert in an MTS Visual Basic component. The following sample code can to used to display error messages while debugging Visual Basic code. You can also use this in conjunction with the Microsoft Windows NTŪ debugger (WinDbg.exe), which is a 32-bit application that, along with a collection of DLLs, is used for debugging the Kernel, device drivers, and applications. Note that you must enter DEBUGGING = -1 in the Conditional Compilation dialog box (located on the Make tab of the Project Properties dialog box) to enable the assert.
The following code provides an example.
#If DEBUGGING Then 'API Functions Private Declare Sub OutputDebugStringA _ Lib "KERNEL32" (ByVal strError As String) Private Declare Function MessageBoxA _ Lib "USER32" (ByVal hwnd As Long, _ ByVal lpText As String, _ ByVal lpCaption As String, _ ByVal uType As Long) As Long 'API Constants Private Const API_NULL As Long = 0 Private Const MB_ICONERROR As Long = &H10 Private Const MB_SERVICE_NOTIFICATION As Long = &H200000 Public Sub DebugPrint(ByVal strError As String) Call OutputDebugStringA(strError) End Sub Public Sub DebugMessage(ByVal strError As String) Dim lngReturn As Long lngReturn = MessageBoxA(API_NULL, strError, "Error In Component", _ MB_ICONERROR Or MB_SERVICE_NOTIFICATION) End Sub #End If
You can then run checks through your code to aid stress debugging, such as in the following code:
SetobjObjectContext=GetObjectContext() #If DEBUGGING Then If objObjectContext Is Nothing Then Call DebugMessage("Context is Not Available") #End If