Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method '~' of Object '~' failed

Status
Not open for further replies.

arh

Programmer
Aug 17, 2000
19
0
0
US
When calling one MTS object from another both written in VB6 on a transaction context, the environment sometimes raisers the following error.

-2147164157 Method '~' of Object '~' failed
 
Hi,
I had the same problem. There is a bug in MTS that in case of an error in a component, does not return the original error, but the message that you received. Look into MDSN for more details.

sorin
 
How can you get the real error message? Is it possible?
 
Dear MSDN has all the detail for this error
actually this is the BUG you can get-rid of the bug by installing new service-pack of VB and MTS..
Regards
Nouman
 
This error can occur(even with SP2) if you put a dll in COM+ which has the MTSTransactionMode on a class set to 0 - NotAnMTSObject
 
We have been having the same problem when call SQL stored procedures from a VB6 dll. Does anyone know a way of trapping the errors raised in a SQL 2000 SP so they can be reported to the VB6 dll and handled. The VB6 dll is in COM+.

 
Dear
go for the latest service pack of Windows2000 if u r using Win2k and if WinNT then go for latest service pack for MTS
Regards
Nouman
 
Hi,
Just install MDAC 2.6 and then the problem is fixed.
This error is caused by DLLS which are built with a different MDAC than which is installed in the deployment environment.

Regards
Shirish Sharma
 
I also get this error when the MSDTC service has been stopped and I make a call to a COM component in MTS.
 
We've also had this problem and we've tried all the suggested fixes. In our case we have a VB app calling a VB component which in turn calls a C++ component. Both of the components are running under MTS.
For a test we pass a bad sql statement (eg selecting a non-existent field) from the vb app to the vb component which creates the C++ component that executes the statement on the database.
What gets reported back is the ~ of ~ error message.
If we remove the vb component from MTS and make the same call then we get a good error message returned.
Any ideas?
thanks
 
I ran into this myself recently and I think its because when COM+ components running in a transactions context call the "setABORT" method, then the transaction is considered "no good" anymore. So, maybe what is happening is the transaction context does not allow further processing?
That is what it looks like to me.

Also, make sure you use CreateObject and not the NEW keyword when creating new objects you have written that are subordinate to the transaction context.

For example, lets say we have 3 classes
clsROOT (has transaction required)

clsUpdate1 (updates database 1)
clsUpdate2 (updates database 2)

clsROOT

public Sub CallUpdates
dim objUPDATE1 as clsUpdate1
dim objUPDATE2 as clsUpdate2
set objUPDATE1 = CreateObject("YOURDLL.clsUpdate1")
set objUPDATE2 = CreateObject("YOURDLL.clsUpdate2")
' now lets say we call the update method of clsupdate1
objupdate1.Update
'and lets say that objupdate1 had an error and
'it called getobjectContext.setabort()
'At this point, I would get the method ~ of
'object ~ 'failed error prior to being able
'to call the objUpdate2.update
objUpdate2.Update
end sub

There are some references on msdn to it being caused by visual basic calling "into the failed object" again to get extended error information, but the solution to that was to apply the latest service pack (which I already had).

At any rate, as I said its almost as if the "set abort" in this example, invalidated the transaction context, thus COM+ decided since the transaction is invalidated, to stop allowing calls to that transaction context.

I solved it by raising an error to clsROOT from the subordinate class modules when an error is called (and after setabort was called by the subordinate class module).

to make this clearer...
clsUPDATE1
public sub Update()
on error goto errhandler:
'also you should explicitly call the disablecommit
'method of object context priot to update processing.
'processing goes here

exit sub
errhandler:
GetObjectContext.setAbort 'abort com+ transaction
err.raise 99999, "COM+ transaction failed"
end sub

'now as long as you have an error handler in the root object to "catch" the failed error, it will correctly abort and also not attempt to call any more methods in the routine.

'for example, this is the root object now
public sub CallUpdates
on error goto errhandler:
dim objUPDATE1 as clsUpdate1
dim objUPDATE2 as clsUpdate2
set objUPDATE1 = CreateObject("YOURDLL.clsUpdate1")
set objUPDATE2 = CreateObject("YOURDLL.clsUpdate2")
' now lets say we call the update method of clsupdate1
objupdate1.Update
'and lets say that objupdate1 had an error and
'it called getobjectContext.setabort()
'At this point, I would get the method ~ of
'object ~ 'failed error prior to being able
'to call the objUpdate2.update
objUpdate2.Update
exit sub
errhandler:
msgbox "com+ component was aborted."
end sub

Hope this helps, sorry if I didnt explain it so well, but that is what it appeared to happen to me in regards to this.
Whats weird is the COM+ documentation does not seem to make an explicit reference to having to "raise an error and catch it the root object".

Anybody care to join in here?

Thanks...
Gilbert M. Vanegas
Programmer Analyst III
County of San Bernardino - ISD
Email : gvanegas@isd.sbcounty.gov
 
We are having the "Method '~' of object '~' failed" problem with a VB DLL calling a COM+ Application which then retrives recordsets from Oracle. It worked just fine on the test server, but with the same install on the new production server we were not as lucky.
Has anybody ever seen this as a problem between Oracle and COM+? If we put a different connection string in COM+ to point to the old test database, our recordsets are returned with no problem.

Thanks for any help!
 
Does any one have any idea what service pack fixes this issue? Is it SP 4 or 5?


Smilee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top