【发布时间】:2015-09-25 16:37:42
【问题描述】:
C# 新手并拥有一个访问 Windows WMI 的控制台应用程序。我补充说:
using System.Management;
using System.Management.Instrumentation;
还添加了引用并将两个引用上的“CopyToLocal”设置为 true。我确实在“bin/debug”目录中看到了两个 .dll,但是,当在另一台计算机上运行时(我没有在其中编译源代码),我仍然收到两个引用未找到的错误。
我得到的例外是:
未处理的异常:System.UnauthorizedAccessException:访问 ID 被拒绝。 (来自 HRESULT 的异常: System.Runtime.InteropService.Marshal.ThrowExcetpionForHRInternal(Int32 errorcCode, IntPtr, errorInfo) 的 System.Runtime.InteropService.Marshal.ThrowExceptionForHR(Int32 errorCode) 的 System.Management.ManagementScope.InitializeGuts 的 0x80070005 (E_ACCESS_DENIED)对象 o) 在 System.Management.ManagementScrope.Initialize() 在 System.Management.ManagementScopt.Connect()
我真的很感谢所有的帮助!
【问题讨论】:
-
您只是将 .exe 或整个调试文件夹复制到另一台计算机吗?
-
您永远不会收到“找不到两个引用”的错误消息。不要将 Copy Local 设置为 true,请引用 exact 错误消息。
-
我都尝试了 - 只是复制我的首选方法“.exe”和整个项目文件夹。实际错误是:未处理的异常:System.UnauthorizedAccessException:访问 id 被拒绝。 (来自 HRESULT 的异常: System.Runtime.InteropService.Marshal.ThrowExcetpionForHRInternal(Int32 errorcCode, IntPtr, errorInfo) 的 System.Runtime.InteropService.Marshal.ThrowExceptionForHR(Int32 errorCode) 的 System.Management.ManagementScope.InitializeGuts 的 0x80070005 (E_ACCESS_DENIED)对象 o) 在 System.Management.ManagementScrope.Initialize() 在 System.Management.ManagementScopt.Connect()
-
我已将异常消息复制到问题中,以方便他人查看。