System.UnauthorizedAccessException: 创建 COM 组件的实例失败,出现错误 80070005 (C#)
System.UnauthorizedAccessException: Creating an instance of the COM component fails with error 80070005 (C#)
我在使用 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 应用程序的类似线程,我应该在 "DCOM Config" 选项卡中看到 COM 对象 dcomcnfg /32
,但是我找不到任何相关的 CLSID。我试过 运行 dcomcnfg
没有 '/32' 后缀,但也没有成功。我需要从中获取数据的主要应用程序是 32 位的(我们称之为母应用程序)。
有什么建议可以解决这个问题吗?我将不胜感激。谢谢!
确保 Windows 服务 运行 在有权访问 COM 组件的帐户下。
您可以通过启动 regedt32.exe 检查这些权限,转到 HKCR\CLSID{D64DB4A9-3B26-4D2B-B556-9DA433C54175},右键单击并选择 "Permissions..."。
我在使用 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 应用程序的类似线程,我应该在 "DCOM Config" 选项卡中看到 COM 对象 dcomcnfg /32
,但是我找不到任何相关的 CLSID。我试过 运行 dcomcnfg
没有 '/32' 后缀,但也没有成功。我需要从中获取数据的主要应用程序是 32 位的(我们称之为母应用程序)。
有什么建议可以解决这个问题吗?我将不胜感激。谢谢!
确保 Windows 服务 运行 在有权访问 COM 组件的帐户下。
您可以通过启动 regedt32.exe 检查这些权限,转到 HKCR\CLSID{D64DB4A9-3B26-4D2B-B556-9DA433C54175},右键单击并选择 "Permissions..."。