[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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
0
pipe
Asked:
pipe
1 Solution
 
dentyneCommented:
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
 
rkot2000Commented:
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
 
pipeAuthor Commented:
ok, im running w2k sp2. im a little confused on what i need to do.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bhhCommented:
Listening...
0
 
rkot2000Commented:
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
 
rkot2000Commented:

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
 
BettikCommented:
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
 
pipeAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now