random .NET and web development musings

Want to see the most unhelpful code ever written?

Check out System.Transactions.TransactionManager.ValidateTimeout:

internal static TimeSpan ValidateTimeout(TimeSpan transactionTimeout)
{
    if (transactionTimeout < TimeSpan.Zero)
    {
        throw new ArgumentOutOfRangeException("transactionTimeout");
    }
    if (!(MaximumTimeout != TimeSpan.Zero) || ((transactionTimeout <= MaximumTimeout) && !(transactionTimeout == TimeSpan.Zero)))
    {
        return transactionTimeout;
    }
    return MaximumTimeout;
}

So thats saying, if you provide a timeout greater than the machine.config value, ignore it and use the machine.config one. Silently. No complaining, no warning.

To increase the machine.config timeout you need to add the following to machine.config (or adjust existing values if they are present):'

<system.transactions>
  <machineSettings maxTimeout="02:00:00"/>
  <defaultSettings timeout="02:00:00"/> 
 </system.transactions>
2 COMMENTS
Rohan Cragg
November 10, 2011
ad

Thanks. Also quoted you here for the greater good :-) http://stackoverflow.com/q/5915462/5351

November 10, 2011
ad

Thanks :) Hope this was useful

Post a comment