了解Windows中的MSDTC

AJ.*_*AJ. 4 c# subsonic msdtc transactions

要在Subsonic中使用事务构造(如下所示),MSDTC需要在Windows机器上运行.对?

        using (TransactionScope ts = new TransactionScope())
        {
            using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
            {
                // update table 1
                // update table 2

                // ts.commit here

            }
        }
Run Code Online (Sandbox Code Playgroud)
  1. MS-DTC是Windows系统(XP,Vista,Windows 7,服务器等)上的默认服务吗?
  2. 如果未启用,我如何确保在我的应用程序的安装过程中启用它?

Ran*_*ica 7

MSDTC应该安装windows.如果不是,则可以使用以下命令进行安装:

msdtc -install
Run Code Online (Sandbox Code Playgroud)

您可以使用sc.exe配置MSDTC服务.将服务设置为自动启动并启动服务:

sc config msdtc start= auto
sc start msdtc
Run Code Online (Sandbox Code Playgroud)

请注意,您需要管理员权限才能执行上述操作.