Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

3

code:

ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();

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

Error:

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

c#
wmi
asked on Stack Overflow Jun 19, 2013 by smitha • edited Jun 19, 2013 by RRUZ

5 Answers

4

The Error code 0x80070005 is related to the WMI permissions.

0x8007xxx : Errors originating in the core operating system. WMI may return this type of error because of an external failure, for example, DCOM security failure.

In order to fix this error you must set the proper permissions in the client and server machines. Try these links

answered on Stack Overflow Jun 19, 2013 by RRUZ
0

Also Please allow the app "windows management instrumentation (wmi)" to communicate through windows firewall. Please refer this link for more info. https://social.msdn.microsoft.com/Forums/vstudio/en-US/6229334e-d5ef-4016-9e7e-1c8718be8d43/access-is-denied-exception-from-hresult-0x80070005-eaccessdenied-in-vbnet?forum=netfxbcl

answered on Stack Overflow Oct 21, 2016 by Somnath
0

tick checkbox of capabilities in appxmanifest in case of UWP app.

answered on Stack Overflow Jul 3, 2018 by Neelam Prajapati
-1

Did you try enabling Anonymous access for the site in IIS?

Edit:

The error message clearly says what you need to do.

Use a separate limited account for the site if you want or enable anonymous access for the site in IIS.

answered on Stack Overflow Jul 13, 2016 by ali hesham
-1

The error 0x80070005 usually relates to permission denied to the cache files, so make sure they've the right permissions.

For example go to /Users/Public/Application Data/Package Cache folder (or other folder) and make sure that the folders and files there has the right permissions. Otherwise find out which temporary/cache files are causing the issue and remove them.

answered on Stack Overflow Sep 19, 2017 by kenorb

User contributions licensed under CC BY-SA 3.0