Should I use TransactionScope?

  • Thread starter Thread starter hardieca
  • Start date Start date
H

hardieca

Hi,

I'd really like to use TransactionScope within the Business Layer of
my web application. A book I'm reading makes a note that it should not
be used in a shared web hosting environment because the server may get
re-configured. Can anyone elaborate on this?

Regards,

Chris
 
Chris,

I don't see how the server becoming reconfigured affects the use of
TransactionScope.

You want to use the TransactionScope class when you want the code
encapsulated in the scope of the instance (it's meant to be used in a using
statement) is to run in a transactional context.

Look at the documentation for the TransactionScope class on how to use
it.

Hope this helps.
 
I don't see how the server becoming reconfigured affects the use of
TransactionScope.

Maybe if DTC is disabled... but by that note, virtually everything is
a contender... almost *any* configuration change could potentially
break something... all our code will always be at the mercy of the
services that the OS and runtime provide

Marc
 
Marc Gravell said:
Maybe if DTC is disabled... but by that note, virtually everything is
a contender... almost *any* configuration change could potentially
break something... all our code will always be at the mercy of the
services that the OS and runtime provide

Actually, TransactionScope is supposed to work even if DTC is
disabled/uninstalled, as long as you don't do anything that causes
promotion. I've actually got an open bug report on Connect about this (i.e.
it failed for me when DTC wasn't installed), but I've been communicating
with a tester at MSFT who's working on the bug and he can't get it to
reproduce. Indeed, when I tried to repro it myself, I couldn't do it
either - as long as the transaction doesn't need to be promoted, DTC should
not be required.

-cd
 
Correct; but the OP didn't specify an RDBMS; only MS SqlServer 2005
supports promotable transactions; prior to this you will get DTC
immediately, without promotions even being an issue.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top