serverProtocolsManagement.Get()以下 WMI 查询在何时是无效的服务器名称时引发异常sqlHost(如预期的那样。但是,如果我尝试使用相同的无效参数再次调用此代码,则ManagementScope构造函数将无限期挂起(从不返回或引发错误,只是挂起)。对此有合理的解释吗?    
try {
        ManagementScope managementScope = new ManagementScope(@"\\" + sqlHost + @"\root\Microsoft\SqlServer\ComputerManagement");
        using (ManagementClass serverProtocolsManagement = new ManagementClass(managementScope, new ManagementPath("ServerNetworkProtocol"), null)) {
            serverProtocolsManagement.Get();
            using (ManagementObjectCollection protocols = serverProtocolsManagement.GetInstances()) {
                foreach (ManagementObject protocol in protocols ) {
                    protocol.Get();
                    if ((string)protocol.GetPropertyValue("ProtocolName") == "Tcp" &&
                        (string)protocol.GetPropertyValue("InstanceName") == sqlInstanceName) {
                        protocol.InvokeMethod("SetEnable", null);
                    }
                }
            }
        }
    } catch (COMException ex) {
        MessageBox.Show(ex.ToString());
    }
编辑:
我尝试过使用不同的超时选项(通过将ConnectionOptions对象传递给ManagementScope构造函数),但无济于事。
编辑#2:
我不知道为什么我没有想到这一点(尽管它仍然不应该是一个问题):我在调试时从 VS 中的即时窗口调用此代码。一定存在某种线程问题,因为一旦我将此代码链接到 Windows 窗体按钮,一切正常。谢谢您的帮助!!