以下代码引发System.IO.FIleNotFoundException:
System.Management.ManagementClass m = new System.Management.ManagementClass("Win32_OperatingSystem");
DateTime lastBootUpTime = new DateTime();
foreach (System.Management.ManagementObject instance in m.GetInstances())
{
lastBootUpTime = ParseCIM_DATETIME(instance["LastBootUpTime"].ToString());
}
foreach
行引发异常。下面的异常详细信息表明它在GetInstances
方法中。我已经查看了所有可以找到的相关内容,但似乎没有任何适用内容。
此异常在自2014年以来每天都成功运行的客户PC上反复发生。它未连接到Internet。我获悉,此后没有对PC或C#程序进行任何配置更改或Windows更新。有一个由程序更新的本地SQL Server Express数据库,仅此而已。
我看不到静态的东西怎么会这样失败。我在查看某种内存或磁盘损坏吗?