代码:访问被拒绝。 (异常来自HRESULT:0X80070005(E_ACCESSDENIED)
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
上面的代码抛出以下异常,请Help..i阅读一些文章,这个错误被抛出由于WMI腐败是这种情况?我一定要重建WMI或是否有任何备用或更好的解决方案
错误:?
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at System.Management.ManagementScope.InitializeGuts(Object o) at System.Management.ManagementScope.Initialize() at System.Management.ManagementScope.Connect() at WebApplication3.lanusers.Button1_Click1(Object sender, EventArgs e) in C:\Users\user\documents\visual studio 2010\Projects\WebApplication3\WebApplication3\lanusers.aspx.cs:line 120 IpAddress192.168.1.55HostNamenkn-PC
我认为这需要管理员访问,你有没有尝试作为管理员运行? – Dinesh
是的,我以管理员身份运行 – smitha