locked
Got this error Time-out interval must be less than 2^32-2.

    Question

  • Hello,

    I have the following error:

    System.ArgumentOutOfRangeException: Time-out interval must be less than 2^32-2.

    Parameter name: dueTm

    And my code looks like this:

    [TestMethod]
    public void TransactionTest()
    {
    
     TransactionOptions transactionOptions = new TransactionOptions();
     transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
     transactionOptions.Timeout = TimeSpan.MaxValue;
    
     using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
     {
     /* Writing to database with EF 4 */
    
     NestedMethod();
     
     transactionScope.Complete();
     }
    }
    
    public void NestedMethod()
    {
     TransactionOptions transactionOptions = new TransactionOptions();
     transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
     transactionOptions.Timeout = TimeSpan.MaxValue;
    
     using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
     {
    
     /* Writing to database with EF 4 */
    
     transactionScope.Complete();
     }
    }
    

     

     

    I get the error when initializating the transaction scope in the nested method. I can avoid it if I do not set the TransactionOptions on the nested TransactionScope, but I'd like to know why the error happens.

    Thanks for any reply.

    Regards




    Friday, April 29, 2011 9:11 AM

Answers

  • Hi,

    I did some investigation and noticed that this is a bug on our side and we will take a look on how to fix it. Eitherway, note the following:

    * It doesnt make sense to set a timeout for a nested transaction scope where nestedTSTimeout >= rootTSTimeout as the root transaction Scope timeout will expire first and will abort the transaction

    * The max value for a transaction timeout is  TransactionManager.MaximumTimeout that retrieves it from the machine.config. If you try to set it to TimeSpan.MaxTime, it will ignore it and use TransactionManager.MaximumTimeout instead. (For more information take a look on this thread: http://social.msdn.microsoft.com/forums/en-US/windowstransactionsprogramming/thread/250b40b9-0838-4142-a8ff-d9d26690083b/)

     

    So, I think that you could update your code based on those following notes.

    Let me know if you still have any question.

    Thanks,


    Rafael Barcelos - SDET Transactions/Agreements Team
    Friday, April 29, 2011 10:15 PM
    Moderator

All replies

  • Hi,

    I did some investigation and noticed that this is a bug on our side and we will take a look on how to fix it. Eitherway, note the following:

    * It doesnt make sense to set a timeout for a nested transaction scope where nestedTSTimeout >= rootTSTimeout as the root transaction Scope timeout will expire first and will abort the transaction

    * The max value for a transaction timeout is  TransactionManager.MaximumTimeout that retrieves it from the machine.config. If you try to set it to TimeSpan.MaxTime, it will ignore it and use TransactionManager.MaximumTimeout instead. (For more information take a look on this thread: http://social.msdn.microsoft.com/forums/en-US/windowstransactionsprogramming/thread/250b40b9-0838-4142-a8ff-d9d26690083b/)

     

    So, I think that you could update your code based on those following notes.

    Let me know if you still have any question.

    Thanks,


    Rafael Barcelos - SDET Transactions/Agreements Team
    Friday, April 29, 2011 10:15 PM
    Moderator
  • I'm running into the same situation. Any idea when the fix will be available? In my case, I have parent A and parent B that call the same nested method. Parent A starts a transaction, while parent B does not. Because nested method joins transaction or starts new one, everything works except inability to specify matching timeout causes me some grief.
    Thursday, July 14, 2011 5:32 PM