0
votes

I have a WCF service consumed by a Windows Workflow via a transaction. I have a method that calls a stored procedure using EF.

The stored procedure takes a long time to return a result, I get the following exception:

The transaction under which this method call was executing was asynchronously aborted.

When I set the TransactionTimeout via ServiceBehaviour attribute, everything works fine:

[ServiceBehavior(TransactionTimeOut="00:02:00")]

But when the TransactionTimeOut was set via app.config, it's not working and I get the above exception.

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceTimeouts transactionTimeout="00:02:00"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

I have also tried <System.transaction> but I'm still getting the error.

Thanks in advance for your help.

2
Is the transaction taking longer than 2 minutes?Ryan Wilson
No, it takes about 1 minute and 30 secondsBilel Chaouadi
From what I see on here: (docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/…), it looks as if you should have the transactionTimeout as part of your behavior node, as it's attribute.Ryan Wilson
I don't want hard code the value via the attribute, I just want use the app.configBilel Chaouadi

2 Answers

0
votes

To increase timeouts use following mark-up:

<system.serviceMdel>
    <bindings>
        <httpBinding>
            <binding ... receiveTimeout="..." sendTimeout="...">
            </binding>
        </httpBinding>
    </bindings>
</system.serviceMdel>

Refer to this Microsoft document.

0
votes

According to Microsoft documentation : If this attribute is set within a service configuration section, you should apply at least one method of the corresponding service with OperationBehaviorAttribute, in which the TransactionScopeRequired property is set to true.

I have just added [OperationBehavior(TransactionScopeRequired = true)] to the service method, then I consulmed it inside a TransactionScope and everything is working fine.