Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# “面对错误”;System.IO.FileNotFoundException:“0”;_C#_.net_Sql Server_Wmi - Fatal编程技术网

C# “面对错误”;System.IO.FileNotFoundException:“0”;

C# “面对错误”;System.IO.FileNotFoundException:“0”;,c#,.net,sql-server,wmi,C#,.net,Sql Server,Wmi,我是一个C语言的人,刚接触C语言,我必须调试项目代码中的一个错误。 需要C#专家的帮助,我读了一些关于这方面的文章,但未能找到解决方案 我在Windows 2012 server计算机上安装了SQL 2012 express edition,并尝试运行以下代码。 使用Visual Studio 2010 using System; using System.Management; public class Example { public static void Main()

我是一个C语言的人,刚接触C语言,我必须调试项目代码中的一个错误。 需要C#专家的帮助,我读了一些关于这方面的文章,但未能找到解决方案

我在Windows 2012 server计算机上安装了SQL 2012 express edition,并尝试运行以下代码。 使用Visual Studio 2010

using System;
using System.Management;

public class Example
{
    public static void Main()
    {
        ManagementScope scope = new ManagementScope(@"\\" + Environment.MachineName + @"\root\Microsoft\SQLServer\ComputerManagement11");

        string instanceName, ipAddressName, propertyName, protocolName;
        using (ManagementClass networkProtocolMan = new ManagementClass(scope, new ManagementPath("ServerNetworkProtocolProperty"), null))
        {
            networkProtocolMan.Get();
            Console.WriteLine("" + networkProtocolMan.Path);         
            ManagementObjectCollection moCollection = networkProtocolMan.GetInstances(); //Class gets filled with error here
                                                                                        //used debugger to look inside moCollection   
            Console.WriteLine(""+moCollection.Count); //Error is getting printed on console here
            ManagementObject mo;
            ManagementObject protocolProperty = null; ;
        }
        return;
    }
}
我得到的错误是:

System.IOFileNotFoundException:

在 System.Runtime.InteropServices.Marshal.ThroweException for hr内部 在System.Runtime.InteropServices.Marshal.ThroweExceptionForHR 位于System.Management.ManagementObjectCollection.ManagementObjectEnumeration.moveNext

在System.Management.ManagementObjectCollection.get_Count

在放置断点之后,我看到在moCollection->Count value中

“mocloection.Count”引发了类型为“System.IO.FileNotFound”的异常 类型为:int{System.IO.FileNotFoundException}


我无法在这里发布调试器屏幕截图,因此我尝试将其描述为如上所述。请指导我解决此错误。

这与sql server有什么关系?请参阅此“\root\Microsoft\SQLServer\ComputerManagement11”我安装了64位sql server 2012。此错误表示WMI路径不存在。这是一个问题。尝试测试路径以确保可以使用ITI如果无法使用WBEMTest连接,则可能存在权限问题或WMI提供程序注册问题,如[KB文章]9中所述https://support.microsoft.com/en-us/kb/956013)