gpt4 book ai didi

c# - 访问被拒绝。 (来自 HRESULT : 0x80070005 (E_ACCESSDENIED) 的异常

转载 作者:行者123 更新时间:2023-11-30 17:04:43 29 4
gpt4 key购买 nike

代码:

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

上面的代码抛出以下异常请帮助..我在一些文章中读到这个错误是由于 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

最佳答案

错误代码0x80070005与WMI权限有关。

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.

为了修复此错误,您必须在客户端和服务器计算机中设置适当的权限。试试这些链接

关于c# - 访问被拒绝。 (来自 HRESULT : 0x80070005 (E_ACCESSDENIED) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17187871/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com