December 8th, 2011, 12:19 PM
Converting ASP.Net to .Net 4.0 throws MSDTC error
Hi - I've just converted an ASP.Net 2.0 solution to 4.0. In general, it seems to work fine, but there's one point in the code that consistently throws an error on 2 Windows 7 machines, one 32-bit, one 64-bit. The same code works fine on a Windows 2003 machine in the 2.0 framework. Note that both versions are being run through Visual Studio, the 2.0 version in VS2005, the 4.0 version in VS2010. I also get the same error message if I publish the 4.0 version to a Windows 7 machine and run it from IIS or in the browser (IE9). The code that breaks is as follows:
string strSelect = "SELECT * FROM Tasks WHERE UserID = " + UserID + " AND ClsdDate IS NULL AND Task LIKE 'Employee Move - " + RequestItemName + "%'";
SqlConnection dsConn = new SqlConnection(ConfigurationManager.AppSettings["DSN_TRACKIT"].ToString());
SqlDataAdapter dsDataAdapter = new SqlDataAdapter(strSelect, dsConn);
SqlCommandBuilder dsCommandBuilder = new SqlCommandBuilder(dsDataAdapter);
dsDataAdapter.UpdateCommand = dsCommandBuilder.GetUpdateCommand();
The error message is:
Network access for Distributed Transaction Manager (MSDTC) has been disabled.
Please enable DTC for network access in the security configuration for MSDTC
using the Component Services Administrative tool
Note that the code does not involve a transaction, or more than one SQL Server and my DBA swears that DTC is enabled on ALL SQL Servers involved in this solution.
So what's going on here? I've googled the error message, but I've seen nothing that could explain this. I don't know if this is a Windows 7 issue or a .Net 4.0 issue.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!