"SqlException: MSDTC on server is unavailable" error in C# Code


One of my projects was working properly, and then I shifted it into another pc, now same code, throws the below error for some SQL queries.

SqlException: MSDTC on server is unavailable.

exception-SqlException-MSDTC-on-server-is-unavailable.png

It was working on the last PC without any issue, so I am not sure what's the error

I am using Entity framework in my C#, ASP.NET MVC project.

I am not posting any code, as Code is simple just updating data in the database in the background using HangfireIO.


Asked by:- Vinnu
0
: 259 At:- 4/13/2018 12:18:56 PM
SQL C# ASP.NET






1 Answers
profileImage Answered by:- manish

As explained in your question description that code was working in older pc and now getting error " SqlException: MSDTC on server is unavailable"

Here is the possible solution for it.

  1. Click on Start–>Control Panel->Administrative Tools->Services
  2. Select the service “Distributed Transaction Coordinator”
  3. Right on the service and choose “Start” 

    distributed-services-start-sqlexception-msdtc-on-server-is-unavailable-error-in-c-code-min.png
  4. Also, make this service to run Automatically for solving this issue permanently

    auto-start-service-msdtc-min.png

When SQL Server and the Application Server are on different boxes

The above solution work well when SQL Server and the Application are on the same box. If they are deployed on different boxes then additionally you should follow these steps to correct the problem

  1. Click Start–>Control Panel –> Administrative Tools –> Component Services –> Computers
  2. Right click on My Computer and choose  Properties option
  3. Switch to MS DTC tab and check allow remote access

This should resolve your issue permanently.

2
At:- 4/14/2018 3:03:21 PM Updated at:- 4/14/2018 3:06:00 PM
Thanks 0
By : Vinnu - at :- 4/18/2018 1:20:37 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use