简体   繁体   English

如何在SQL Server Express的本地实例上“唤醒” msdtc

[英]How to “wake up” msdtc on local instance of SQL Server Express

I am trying to use MSDTC to create a transaction that spans the local instance of SQL Server Express and a SQL Server 2012 database. 我正在尝试使用MSDTC创建一个跨SQL Server Express和SQL Server 2012数据库的本地实例的事务。

The first time I run my unit tests after rebooting I get "msdtc is unavailable" when I try to open a connection to the local server within a transaction, I can run the tests several times and get the same result. 尝试在事务中打开与本地服务器的连接时,重新引导后第一次运行单元测试时,我收到“ msdtc不可用”的信息,我可以多次运行测试并获得相同的结果。 If I go into Component Services the Computers folder will be empty for around 5 seconds and then My Computer will eventually appear. 如果进入组件服务,“计算机”文件夹将为空约5秒钟,然后最终将出现“ My Computer I can then successfully run the Unit Tests, without doing anything further in the Component Services window. 然后,我可以成功运行单元测试,而无需在“组件服务”窗口中进行任何进一步的操作。 So it seems like the Component Services window is starting something up in the background, but what? 因此,似乎“组件服务”窗口正在后台启动某些东西,但是又是什么呢?

For Each row As DataRow In ObjectIdsTable.Rows
    Using scope As New Transactions.TransactionScope
        Using serverCon = New SqlConnection(_serverConn)
            Using syncConn As New SqlConnection(_clientConn)
                serverCon.Open()
                syncConn.Open()  **ERROR HAPPENS HERE**

                ... Do work Here ...

            End Using
        End Using
        scope.Complete()
    End Using
Next

I suppose I could rewrite the code to avoid using MSDTC but isn't this exactly what it is for? 我想我可以重写代码以避免使用MSDTC,但这不是它的确切用途吗?

I figured it out. 我想到了。 there is a service called Distributed Transaction Coordinator that was set to start manually. 有一项称为“分布式事务处理协调器”的服务,该服务已设置为手动启动。 Setting that to Automatic fixed the problem. 将其设置为“自动”可解决此问题。

It is not the first time that being forced to present the problem in a complete/logical manner so as to create a proper SO question has helped me resolve it myself. 第一次被迫以完整/逻辑的方式提出问题以提出适当的SO问题帮助我自己解决了这不是第一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM