views:

19

answers:

1

I have WebService that is hosted by ASP.NET web site. Inside the TransactionScope object is used to handle transactions:

        using (TransactionScope scope = new TransactionScope())
        {
            ...
            scope.Complete();
        }

The problem is that during debugging, when I am going through each line in step-by-step mode, transaction timeout is occurred and any attempt to access DB crashed with '' error, and as a result: further debugging is prohibited.

How could I handle that without deleting mentioned lines of code?

P.S. I've tried to find, how to increase a time-out of created transaction, but didn't find something helpful.

Any thoughts are welcome.

Thanks.

+2  A: 

You can specify an infinite timeout for the Transaction by passing in a zero length TimeSpan as part of the constructor:

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0)))

The TransactionScopeOption of Required is what is used as default with your parameterless constructor.

See http://msdn.microsoft.com/en-us/library/ms172152(VS.90).aspx for more information.

DavidGouge
this will require changing the source code each time before debugging? As a solution it could be creating TrasactionScope factory that will take infinite transaction in debug mode...If there are no any other option, I will try to look how to control 'DEBUG' variable in ASP.NET application...
Budda
Yeah, of course. Use a factory and check if running in debug mode.
DavidGouge