You are currently offline, waiting for your internet to reconnect

How To Avoid "Error 91" when Debugging MTS Components with Visual Basic

This article was previously published under Q188919
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
SUMMARY
When developing Visual Basic components to run under control of MicrosoftTransaction Server (MTS), if your object uses ObjectContext, you mayencounter the following error when trying to debug them within the VisualBasic environment:
Run-Time Error '91': Object variable or with block variable not set.
This article describes how to configure Visual Basic to allow you to debugthese components using the special debug version of GetObjectContext.

There are two ways to avoid this error when writing Visual Basiccomponents. The first is to configure Visual Basic to use a special versionof the object context. The second way is to use the Microsoft DeveloperStudio environment.
MORE INFORMATION
To facilitate application debugging using Visual Basic, you can debug acomponent that uses ObjectContext by enabling a special version of theobject context. This debug-only version is enabled by creating thefollowing registry key:
   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Transaction        Server\Debug\RunWithoutContext				

Steps to Create the Registry Key

  1. Start Regedit and locate the following registry key:
       HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Transaction Server						
  2. Select the Transaction Server key, right-click the selection and choose New. Next, choose Key and then name this new key Debug.
  3. Now, select the Debug key, right-click and then choose New. Next, choose Key and then name this new key RunWithoutContext.
Now that this registry entry is present on your computer, you should now beable to run your MTS component using Visual Basic.

NOTE: When running in debug mode, none of the functionality of MTS isenabled. GetObjectContext returns the debug ObjectContext rather thanreturning Nothing.

When running in this debug mode, the ObjectContext operates as follows:

  • ObjectContext.CreateInstance - Calls COM CoCreateInstance (no context flows, no transactions, and so on).
  • ObjectContext.SetComplete - No effect.
  • ObjectContext.SetAbort - No effect.
  • ObjectContext.EnableCommit - No effect.
  • ObjectContext.DisableCommit - No effect.
  • ObjectContext.IsInTransaction - Returns FALSE.
  • ObjectContext.IsSecurityEnabled - Returns FALSE.
  • ObjectContext.IsCallerInRole - returns TRUE (same as normal when IsSecurityEnabled is FALSE).
REFERENCES
For more information on debugging compiled Visual Basic components usingthe Microsoft Developer Studio environment, please see the followingarticles in the Microsoft Knowledge Base:
166275 How To Debug a Native Code Visual Basic Component in VC++
244457 How To Debug an MTS Visual Basic Component Running Under ASP
Microsoft Transaction Server 2.0 Help; search on: "Debugging Visual BasicMTS Components"
kbdse kbMTS100 kbMTS200 kbVBp500 kbVBp600 kbRegistry
Properties

Article ID: 188919 - Last Review: 08/30/2004 19:37:32 - Revision: 1.2

  • Microsoft Transaction Services 1.0
  • Microsoft Transaction Services 2.0
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • kbbug kbdebug kberrmsg kbhowto KB188919
Feedback