> The problem for me comes when a transaction is supposed to fail. I've
> modified my child class so that it tries opening an incorrectly-spelled
[quoted text clipped - 4 lines]
> transaction when an exception occurs, but it doesn't appear to be the case
> here.

Signature
Tomas Restrepo
tomasr@mvps.org
Thanks for the clarification, Tomas.
I'm a little confused with the ramifications however, and wondered if you
could suggest a way to deal with the situation? Right now it sounds like my
exception handler is getting in the way, almost-- I get an error, catch it
in the handler, and then the COM+ transaction continues along its merry way,
even though it shouldn't. Is the "proper" procedure here to manually vote
against the transaction in my handler, or are there better ways of going
about this?
Appreciate the help,
--Jim
> Jim,
>
[quoted text clipped - 16 lines]
> of the outer component, since otherwise, you'll get the infamous
> "transaction wanted to commit but transaction rolled back" error...
Tomas Restrepo \(MVP\) - 17 Aug 2004 02:02 GMT
Hi Jim,
> I'm a little confused with the ramifications however, and wondered if you
> could suggest a way to deal with the situation? Right now it sounds like my
[quoted text clipped - 3 lines]
> against the transaction in my handler, or are there better ways of going
> about this?
Yes, and no.
Yes, an option would be to explicitly doom the transaction from your
handler. That's a good practice, anyway (you can use ContextUtil.SetAbort()
for that or any other option, for that).
That said, you still need to ensure that the calling component knows that
your child component is dooming the transaction, otherwise, nasty errors
that are very hard to track down can appear. Consider, for example, the case
when Component A (parent) calls Component B, which silently dooms the
transaction, and then A goes on and tries to create component C on the same
transaction. or it tries to open up a new DB connection. That will fail with
wierd errors like "transaction cannot be null"; or cannot enlist on a
transaction already commited or aborted, or things like that.
Believe me, you don't want to find yourself in that situation ;) Play it
safe: catch the exception, do what you want, the bubble it up.

Signature
Tomas Restrepo
tomasr@mvps.org