COM+包含事务的类调用时的-2147164157错误原因和解决

来源:互联网 发布:同学帮软件 编辑:程序博客网 时间:2024/05/17 13:09

COM+包含事务的类调用时的-2147164157错误原因和解决

 

一个需要事务的类每次当创建另一个COM+对象时就出现如下错误:

Method '~' of object '~' failed

错误号:-2147164157

 

调试良久,终不得其解,google新闻组搜索,得到下面信息

 

Error Number: 
   0x8004E003   ( -2147164157 )
Error Description: 
   You made a method call on a COM+ component 
   that has a transaction that has already aborted or 
   in the process of aborting.
 
This can be caused by two things that are known at this time:  
 
1)  SetComplete has been called after SetAbort was already called in the
transaction, and then a method of the object in the transaction is called  
 
2)  The method on the object is called when the transactions has been 
cleaned
up due to a transaction timeout.
 
*** TRY THIS *** 
1)  After Calling SetAbort() raise an error (Err.Raise) to the caller so 
they can handle
the abort correctly  2)  Increase the transaction timeout for long queries, 
or updates.
 
According to your description, you are pretty sure Child calls SetAborts 
and Parent calls SetAborts. However its important to manually raise the 
error from the child using Err.Raise after calling SetAbort.
 
Also, if you are using W2K, install SP1

 

 

以上信息似乎对我还是没有用,突然间我想到COM+的事务管理不支持嵌套,那么会不会在不同的包(package)之间其事务边界(bound)已经失效呢?因为我为了安装代理包方便,把组件按照功能和类型放在了不同的COM+应用程序中,这样的话就有了跨包(package)的调用和创建对象,当不使用事务时,没有什么问题;一旦在事务中调用和创建,便出现如上错误。我原来也碰到过这个情况,当时以为是COM+的事务不支持跨计算机的调用,现在终于明白了。

 

解决方法:把组件全部放在一个包内,调试通过。