默认情况下,在访问 SQL Server 2005 Express 时使用 System.Transaction.TransactionScope 的情况下,会出现以下错误
MSDTC on server ‘(server name)\SQLEXPRESS’ is unavailable.
原因是 DTC 在默认情况下是被禁用的,需要手动启用。在 Windows XP 和 Windows Vista 下启用的步骤稍有不同,以下是 Vista 下的启用步骤:
-
Click Start, click Run, type dcomcnfg and then click OK to open Component Services.
-
In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.
-
Right click Local DTC and click Properties to display the Local DTC Properties dialog box.
-
Click the Security tab.
-
Set the following options on the Security tab of the Local DTC Properties dialog box and click OK.
Configuration Option Default Value Recommended Value Network DTC Access
Disabled
Enabled
Client and Administration
Allow Remote Clients
Disabled
Disabled
Allow Remote Administration
Disabled
Disabled
Transaction Manager Communication
Allow Inbound
Disabled
Enabled
Allow Outbound
Disabled
Enabled
Mutual Authentication Required
Enabled
Enabled if all remote machines are running Win2K3 SP1 or XP SP2 or higher.
Incoming Caller Authentication Required
Disabled
Enabled if running MSDTC on cluster.
No Authentication Required
Disabled
Enabled if remote machines are pre-Windows Server 2003 SP1 or pre- Windows XP SP2.
Enable TIP
Disabled
Enabled if running the BAM Portal.
Enable XA Transactions
Disabled
Enabled if communicating with an XA based transactional system such as when communicating with IBM WebSphere MQ using the MQSeries adapter.
-
Open the Control Panel, open Windows Firewall, and click Change settings to display Windows Firewall Settings.
-
Click the Exceptions tab.
-
Check the box for Distributed Transaction Coordinator and click OK.