.net - How do I use TransactionScope in C#? -


I'm trying to use TransactionScope, but getting the exception to the bottom. The app is running on a different machine than the database, if this is the case I am using SQL Server 2005.

"Network access has been disabled for the Distributed Transaction Manager (MSDTC). Please enable DTC for network access in security configuration for MSDTC by using component service administrative tools." Using

(Transaction skip tsTransScope = new transaction scope ()) {// dot stuff here TTransenscope.full (); }

edit

I have created a few things based on feedback. I am getting this error now:

  {"Error has returned a COM component to the HRESULT E_FAIL call."} {"Communication with the built-in transaction manager has failed. "}  

Solution I think the initial number was accepted in the accepted answer. The second error seems typical for the unit structure. I will post another question for this.

There are properties on the client:

The properties on the server here are:

You need to enable Network DTC Access as described in this. This change should be done on both databases and application servers. Often times DTC is already running on a database server, so I want to see the application server for the first time.

Here besides the "Allow screen management" option, there is a screen shot of what we use: security configuration screenshot

I have not released HRESULT E_Fail yet, but this article was an interesting suggestion:

Another configuration setting that allows you to be aware of (Although I consider it an unusual situation) RestrictRemoteClients is the registry key if If the value of this key is set to 2 (RPC_RESTRICT_REMOTE_CLIENT_HIGH), then MSDTC network transactions will not be able to work properly. MSDTC only supports RPC_RESTRICT_REMOTE_CLIENT_NONE (0) and RPC_RESTRICT_REMOTE_CLIENT_DEFAULT (1) values ​​for more information on RestrimoteClients.

Finally, when you are not specific to your problem, note about using the TransactionScope class is an important thing that is its default setting To use one is the most restrictive of the different serials and it is amazing that it was selected as the default if you do not need locking at this level, so I have an isolation level at a lower limit Recommend setting for ReadCommitted when TransactionScope :

  var scopeOptions = new transaction option (); ScopeOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; ScopeOptions.Timeout = Timespan Maxwell; (Var Scope = New Transaction Scope (Scope option required by transaction.), {// your code here}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -