title: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)
body: <p>code:</p>
  
  <pre><code>ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
  ManagementObjectCollection queryCollection = searcher.Get();
  </code></pre>
  
  <p>Above code throws the following exception please Help..i read in some article that this error are thrown due to WMI corruption?Is this the case?do i have to rebuild WMI or is there any alternate?or a better solution</p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)</p>
    
    <p>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</p>
  </blockquote>