从 .NET 附加到 COM 服务器中的事件时出现 E_ACCESSDENIED 异常
我有一个实现 IConnectionPoint 事件的 C++/ATL COM 服务器。我的客户端是一个附加到事件的 C# 应用程序。当 COM 服务器被创建为 SYSTEM 服务时,客户端可以正确附加到事件。当 COM 服务器创建为 LocalService 服务(首选)时,当我附加到该事件时,我会收到 E_ACCESSDENIED 异常。
当 COM 服务器是 LocalService 时,我该怎么做才能使事件正常工作?
谢谢。
I have a C++/ATL COM server that implements IConnectionPoint events. My client is a C# application that attaches to the events. When the COM server is created as a SYSTEM service, the client can properly attach to the event. When the COM server is created as a LocalService service (preferred), then I get an E_ACCESSDENIED exception when I attach to the event.
What can I do to get the events to work when the COM server is LocalService?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要找到 LocalService 尝试使用的用户,并确保该用户具有访问权限。如果您无法调整整个计算机的访问权限,则可能必须使用
CoInitializeSecurity
并使用已知具有访问权限的身份以编程方式执行此操作。请参阅 http://msdn.microsoft.com/ en-us/library/ms679760(v=VS.85).aspx 了解更多信息。
You'll need to find what user the LocalService is attemping to use, and ensure that user has access. If you can't adjust access for the whole computer, you may have to do it programatically using
CoInitializeSecurity
and using an identity that is known to have access.Refer to http://msdn.microsoft.com/en-us/library/ms679760(v=VS.85).aspx for more information.