
COM+ error handling on SetAbort
You can try this one :
Create on type to store the last error occured:
Type LastErrorType
Description As String
HelpContext As Long
HelpFile As String
LastDllError As Long
number As Long
Source As String
End Type
Public lError As LastErrorType
Then create a subroutine to store the error occured in it which can be as
under:
Public Sub SetLastError()
With lError
.Description = Err.Description
.HelpContext = Err.HelpContext
.HelpFile = Err.HelpFile
.LastDllError = Err.LastDllError
.number = Err.number
.Source = Err.Source
End With
End Sub
Then create one more sub-routine to record the error:
Public Sub RaiseError(byval errsource as string)
Dim lErr As Long, fNumber As Integer
Dim sErr As String
fNumber = FreeFile
Open App.Path & "\Error.log" For Append As #fNumber
Print #fNumber, Now; lError.number; lError.Description;
lError.Source; lError.LastDllError
Close #fNumber
getobjectcontext.SetAbort
Err.Raise lError.number, ErrSource, lError.Description
End Sub
Now in your procedure whenever u want to do the setabort - you can use
err.raise function and trap the error.
In error trapping routine first execute setlasterror function and then
raiseerror function.
Hi!
I've run into a peculiar problem...
This is the setup:
We have a multi-tier web application that access an Oracle db. We have
several VB-components that are in COM+. The webserver run on the same
machine (W2k Adv. server) as the components and access the db on a second
one (Unix).
When an error occur in a transaction component (MTSTransactionMode =
2-RequiresTransaction) we call SetAbort and then tries to log the error
through a common framework object that handles all our logging.
But when we try that we get a message:
You made a method call on a COM+ component that has a transaction that has
already aborted or in the process of aborting.
and in some extreme cases all that bubbles to the ASP-page is: "Method '~'
of object '~' failed".
It seems that after calling SetAbort the transaction-starting-component is
not allowed to create any new objects at all! But then how the *&%# are we
supposed to be able to log the error!!
I've even tried to call the component before SetAbort with the same
result...
Crossing my fingers for help!
Rickard Nord
Sweden