I have a simple update method like below:
public static void Execute()
{
var conn = new SqlConnection(ConnectionString);
conn.Open();
var cmd = new SqlCommand(UpdateQuery, conn);
cmd.ExecuteNonQuery();
}
When I call this method from a Console Application everything works as expected. Since I do not Complete
the TransactionScope update is rollbacked.
using (new TransactionScope())
{
TestUpdate.Execute();
}
I create a WCF service and call this method inside the wcf operation like below. Again everything works as expected. Since I do not Complete
the TransactionScope update is rollbacked.
// Interface
[OperationContract, TransactionFlow(TransactionFlowOption.Allowed)]
void DoWork2();
// Implementation
public void DoWork2()
{
using (new TransactionScope())
{
TestUpdate.Execute();
}
}
// Console App
var client = new StaticServiceClient();
client.DoWork2();
I start a transaction in the Console Application and call the service from the Console Application with in this transaction. When I debug I can see that Transaction.Current
is not null on IIS and I expect code executed in IIS will use this transaction. But below exception is thrown inside conn.Open();
.
The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
// Interface
[OperationContract, TransactionFlow(TransactionFlowOption.Allowed)]
void DoWork();
// Implementation
[OperationBehavior(TransactionScopeRequired = true)]
public void DoWork()
{
TestUpdate.Execute();
}
// Console App
using (new TransactionScope())
{
var client = new StaticServiceClient();
client.DoWork();
}
Console Application is executed on my local machine and WCF service is hosted on my local IIS. Database is on another server in the same network. I believe, first two cases prove that MSDTC is working fine on both my local machine and the database server. Then, what may be the problem with the third case?
<bindings>
<wsHttpBinding>
<binding name="soapBinding" transactionFlow="true">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ServiceLib.StaticService">
<endpoint contract="ServiceLib.IStaticService" name="soap" binding="wsHttpBinding" bindingConfiguration="soapBinding" address="http://localhost:58759/StaticService.svc/Soap" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="soap" transactionFlow="true">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58759/StaticService.svc/Soap"
binding="wsHttpBinding" bindingConfiguration="soap" contract="ServiceReference.IStaticService"
name="soap" />
</client>
User contributions licensed under CC BY-SA 3.0