gpt4 book ai didi

c# - 系统.UnauthorizedAccessException : Creating an instance of the COM component fails with error 80070005 (C#)

转载 作者:可可西里 更新时间:2023-11-01 09:33:19 25 4
gpt4 key购买 nike

我在使用 C# .NET 命令行应用程序时遇到问题,其主要思想是使用 COM 对象从其他程序获取数据。当手动执行或作为 Node.js 服务器中的子进程运行时,它工作正常,但是当整个项目作为 Windows 服务安装时,C# 应用程序响应以下错误:

System.UnauthorizedAccessException: Creating an instance of the COM component with CLSID {D64DB4A9-3B26-4D2B-B556-9DA433C54175} from the IClassFactory failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at CurrentCamUri.Program.Main(String[] args)

从我读到的here在主要关注 Office 应用程序的类似线程上,我应该在 dcomcnfg/32"DCOM Config" 选项卡中看到 COM 对象,但是我找不到任何东西相关的 CLSID。我尝试在没有“/32”后缀的情况下运行 dcomcnfg,但也没有成功。我需要从中获取数据的主要应用程序是 32 位的(我们称之为母应用程序)。

有什么建议可以解决这个问题吗?我将不胜感激。谢谢!

最佳答案

确保 Windows 服务在有权访问 COM 组件的帐户下运行。

您可以通过启动 regedt32.exe 检查这些权限,转到 HKCR\CLSID{D64DB4A9-3B26-4D2B-B556-9DA433C54175},右键单击并选择“权限...”。

关于c# - 系统.UnauthorizedAccessException : Creating an instance of the COM component fails with error 80070005 (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32927392/

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