Recently I happened to work with System.Transactions namespace and SQL 2000.
I have noticed that if we use TransactionScope, then with SQL 2000 the transaction is automatically enlisted in the MSDTC even if we are using single data base.The code works fine if we deply the SQL 2000 on Win2K server, because MSDTC automatically be started if the code runs. Problem comes only when MSDTC is disabled on this Win2k machine.
This is the exception that occurs:
System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException (0x8004D01B): Exception from HRESULT: 0x8004D01B at System.Transactions.Oletx.IDtcProxyShimFactory.ConnectToProxy(String nodeName, Guid resourceManagerIdentifier, IntPtr managedIdentifier, Boolean& nodeNameMatches, UInt32& whereaboutsSize, CoTaskMemHandle& whereaboutsBuffer, IResourceManagerShim& resourceManagerShim) at System.Transactions.Oletx.DtcTransactionManager.Initialize() ---
The above problem occurs if we deploy the SQL 2000 on win2k3 server, because by default all security settings are disabled on the MSDTC on Win2K3. So in order to make it work, we need to configure MSDTC on the Win2k3 server to accept remote requests and other stuff.
Go to Control panel -> Adminstrative Services -> Component Services
Component Services -> Computers -> My Computer
go to properties of MyComputer, select MSDTC TAB
click on 'Security Configuration'
Make sure you check "Network DTC Access", "Allow Remote Client","Allow Inbound/Outbound", "Enable TIP"
Now the code should run fine. Else try after restaring the machine.
Note:
This behavior is different if we use SQL 2005 as SQL 2005 promotes the transaction to use MSDTC only when it's required.
No comments:
Post a Comment