TransactionScope for client and server on different computers
Not so long ago, I needed to separate the web application server and the SQL server (I got a separate machine on which the SQL server was transferred), but I could not get everything started right away.
To group commands in a transaction, TransactionScope is used in the code . However, when the client application (in my case ASP.NET) and the MS SQL server are on different computers, using TransactionScope leads to the following error.
The transaction manager has disabled its support for remote / network transactions.
Locally configured everything. But since the procedure will have to be repeated when deploying on a live server, as well as when moving, I decided to write a short instruction for myself. When I finished, I thought that it might come in handy for someone else.
I must say right away the following bunch of
Vista works for me - the client PC
Windows Server 2008 + SQL Server 2008 - server.
If you have other combinations, then some of the screens in the screenshots will look different for you.
So, in order for everything to work, you need to configure the Distributed Transaction Coordinator on the computer with MS SQL Server, and on the client computer.
Server setup
1. Make sure that the Distributed Transaction Coordinator service is running.
2. Configure Distributed Transaction Coordinator (DTC)
for this
After that, the service will restart.
3. You need to add an exception to the Windows Firewall for Distributed Transaction Coordinator
4. After that, restart the SQL Server service.
Just in case, it’s better to restart the server altogether, although it was enough for me to restart SQL Server.
Client setup
1. It is also necessary to make sure that the DTC service is running.
2. We execute 'dcomcnfg', we go into the same properties as on the server and we tick off
3. Add exceptions to the Windows Firewall
After these steps, everything worked.
You can read more about the purpose of all options here .
Thanks for attention.
To group commands in a transaction, TransactionScope is used in the code . However, when the client application (in my case ASP.NET) and the MS SQL server are on different computers, using TransactionScope leads to the following error.
The transaction manager has disabled its support for remote / network transactions.
Locally configured everything. But since the procedure will have to be repeated when deploying on a live server, as well as when moving, I decided to write a short instruction for myself. When I finished, I thought that it might come in handy for someone else.
I must say right away the following bunch of
Vista works for me - the client PC
Windows Server 2008 + SQL Server 2008 - server.
If you have other combinations, then some of the screens in the screenshots will look different for you.
So, in order for everything to work, you need to configure the Distributed Transaction Coordinator on the computer with MS SQL Server, and on the client computer.
Server setup
1. Make sure that the Distributed Transaction Coordinator service is running.
2. Configure Distributed Transaction Coordinator (DTC)
for this
- We execute the command 'dcomcnfg'
- Next Computers-> My Computer-> Distributed Transaction Coordinator
- Right-click on LocalDTC and select Properties
- Go to the Security tab on it, check the boxes for Network DTC Access , Allow Remote Clients , Allow Inbound , Allow Outbound .
After that, the service will restart.
3. You need to add an exception to the Windows Firewall for Distributed Transaction Coordinator
4. After that, restart the SQL Server service.
Just in case, it’s better to restart the server altogether, although it was enough for me to restart SQL Server.
Client setup
1. It is also necessary to make sure that the DTC service is running.
2. We execute 'dcomcnfg', we go into the same properties as on the server and we tick off
- Network DTC Access
- Allow inbound
- Allow outbound
3. Add exceptions to the Windows Firewall
After these steps, everything worked.
You can read more about the purpose of all options here .
Thanks for attention.