Solved

MTS/COM

Posted on 2001-08-09
8
274 Views
Last Modified: 2013-11-25
hello-

im trying to debug my business layer object from vb 6.
when i call "GetObjectContext" it comes back as nothing.
can i debug this from vb or does it need to be run thru mts to get the object context?

thanks - p

Public Function UpdateLinkCategories(ByVal vnLinkID As Variant, _
    vsCategories As Variant) As Variant

    On Error GoTo err
   
    '' Consts
    Const METHOD = " BXeroxLinkAdmin.UpdateLinkCategories "
   
    Dim mobjContext As ObjectContext
    Dim mobjDXeroxLinkAdmin As DXeroxLinkAdmin.CXeroxLinkAdmin
    Dim mvCategories As Variant
    Dim i As Integer
   
    Set mobjContext = GetObjectContext()
    Set mobjDXeroxLinkAdmin = mobjContext.CreateInstance("DXeroxLinkAdmin.CXeroxLinkAdmin")
   
    Set mobjDXeroxLinkAdmin = New DXeroxLinkAdmin.CXeroxLinkAdmin
   
    '' Delete all the categories for this link. We will reenter all of the
    '' categories below.
    mobjDXeroxLinkAdmin.DelLinkCategories (vnLinkID)
   
    '' Split up the categories
    mvCategories = Split(Trim(vsCategories), ",")
   
    '' Insert all the categories in the junction table
    For i = 0 To UBound(mvCategories)
        Call mobjDXeroxLinkAdmin.InsertSelCategory(vnLinkID, mvCategories(i))
    Next i
   
    Set mobjDXeroxLinkAdmin = Nothing
    mobjContext.SetComplete
    Exit Function
   
err:
    mobjContext.SetAbort
    Set mobjDXeroxLinkAdmin = Nothing
    err.Raise err.Number, err.Source, METHOD & err.Description

End Function
0
Comment
Question by:pipe
8 Comments
 
LVL 1

Expert Comment

by:dentyne
ID: 6368837
It needs to be run through MTS to get the context.  I'm not sure if there is a way to make it use MTS when you run it from the development environment.  But when you are running the program in development it doesn't use MTS.
0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 50 total points
ID: 6368960
for windows nt :

To facilitate application debugging using Visual Basic 6.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:

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)

for winodws 2000 you need sp2 for windows 2000
0
 

Author Comment

by:pipe
ID: 6369208
ok, im running w2k sp2. im a little confused on what i need to do.
0
 
LVL 2

Expert Comment

by:bhh
ID: 6369215
Listening...
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Expert Comment

by:rkot2000
ID: 6369247
i had the same problem and it was some info on istalling sp 2 and do someting else, since i can't install sp2 i did not record q number. you can search support.mircosoft.com

i am using the following ....


Public Function IsIDE() As Boolean
 On Error Resume Next
 IsIDE = True
 Exit Function
 Debug.Assert 1 / 0
 Select Case Err.Number
  Case 0
   IsIDE = False
  Case Else
   IsIDE = True
  End Select
End Function


Public Function Frcs(ByVal lvsLoadDate As String, _
                             ByVal lvsFilter As String) As ADODB.Recordset

  Dim lvsSQL As String
  Dim ljrsData As ADODB.Recordset
  On Error GoTo Error_
 
  lvsLoadDate = ConvertDate(lvsLoadDate)
  lvsSQL = " SELECT CP_FORC_COST_MANUAL_COMMENTS.PART_NUMBER AS PART" & _
               " FROM " & gcsOwner & "CP_PARTS, " & _
                     gcsOwner & "CP_FORC_COST_MANUAL_COMMENTS " & _
               " WHERE (CP_PARTS.PART_NUMBER = CP_FORC_COST_MANUAL_COMMENTS.PART_NUMBER " & _
               " AND CP_PARTS.LOAD_DATE = CP_FORC_COST_MANUAL_COMMENTS.LOAD_DATE) " & _
               " AND CP_FORC_COST_MANUAL_COMMENTS.LOAD_DATE = " & ConvertToDbDate(lvsLoadDate) & _
               lvsFilter
               
  Set ljrsData = New ADODB.Recordset
 
  Call utOpenConnection
 
  With ljrsData
    .CursorLocation = adUseClient
    .Open lvsSQL, mjcnMain, adOpenStatic, adLockReadOnly
    Set .ActiveConnection = Nothing
  End With
 
  Set Frcs = ljrsData
   
  Call utCloseConnection
 
  If IsIDE = False Then
    GetObjectContext.SetComplete
  End If
 
Exit_:
  Exit Function

Error_:
  Dim luError As guError
  luError = ErrorToUDT
 
  Call utCloseConnection(True)
 
  If IsIDE = False Then
    GetObjectContext.SetAbort
  End If
  ForwardError luError, utErrorSource("Frcs ")
 
End Function
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6369258

or if i need to create an object :

  If IsIDE = False Then
    Set ljBus = GetObjectContext.CreateInstance("Frcst_b.CMainSrch")
  Else
    Set ljBus = New Frcst_B.CMainSrch
  End If
0
 

Expert Comment

by:Bettik
ID: 6373171
you dont need to do anything, provided you set your class to something like 'No Transactions'. VB will then run your component in MTS/COM+ on the fly.

Make sure your class Implements ObjectControl too. i wouldnt hold the objectcontext in class scope - just use it as you need to within each method call.
0
 

Author Comment

by:pipe
ID: 6374109
if my dll that is trying to retrieve the objectcontext is compiled and in mts then vb does run it fine.

then problem is that when i want to step thru the code that is trying to get the objectcontext, the context comes back as null.


i read the article that rkot2000 mentioned above.

"...
To facilitate application debugging using Visual Basic 6.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.
..."

this is for windows NT 4.0. i never found anything on W2K. Right now, im just using conditional compliation to get around this. but, if this can be done in NT4.0 then it should be possible in W2K.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now