Link to home
Start Free TrialLog in
Avatar of pipe
pipe

asked on

MTS/COM

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
Avatar of dentyne
dentyne

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.
ASKER CERTIFIED SOLUTION
Avatar of rkot2000
rkot2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pipe

ASKER

ok, im running w2k sp2. im a little confused on what i need to do.
Listening...
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

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
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.
Avatar of pipe

ASKER

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.