.NETGURU
AutoComplete attribute in Serviced Components- how to use?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.component_services.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Jim Bancroft
I'm having some trouble mixing "AutoComplete" attributes and transactions
with my VB .Net components.

Right now, I have two classes --a "parent" and "child"-- that inherit from
the .Net "ComponentServices" class. The parent class creates a new
transaction context (using a Transaction attribute) and calls the child
class, which participates in the transaction as it opens a SqlConnection to
a database and reads the contents of a table. Both classes have the
AutoComplete attribute set on them.

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
table, which triggers an exception. The Catch statement in the child
component is entered, but the transaction appears to complete, at least
according to the transaction statistics page in the COM+ explorer? As I
understand it, the AutoComplete attribute is supposed to abort the
transaction when an exception occurs, but it doesn't appear to be the case
here.

Am I missing a step or have I done something wrong? Do I have to vote
against the transaction my child class's exception handler, and if so,
doesn't that work against the notion of an AutoComplete attribute? Thanks
for your advice.

-Jim

Reply to this message...
 
    
Tomas Restrepo \(MVP\) (VIP)
Jim,

[Original message clipped]

Actually, it is supposed to abort the transaction when the method actually
"throws" an exception (that is, when the exception is not handled internally
by the method and bubbles up outside of it's scope), not merely when the
exception occurs. If the child class handles the exception internally, COM+
will never see it, and thus it will never doom the transaction.

Furthermore, an exception would actually have to bubble up all the way out
of the outer component, since otherwise, you'll get the infamous
"transaction wanted to commit but transaction rolled back" error...
--
Tomas Restrepo
Click here to reveal e-mail address

Reply to this message...
 
    
Jim Bancroft
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

"Tomas Restrepo (MVP)" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Tomas Restrepo \(MVP\) (VIP)
Hi Jim,

[Original message clipped]

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.
--
Tomas Restrepo
Click here to reveal e-mail address

Reply to this message...
 
 
System.Data.SqlClient.SqlConnection
System.EnterpriseServices.ContextUtil




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification