代碼:訪問被拒絕。 (異常來自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