我在使用 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 https://stackoverflow.com/questions/1491123/system-unauthorizedaccessexception-retrieving-the-com-class-factory-for-word-in在主要关注 Office 应用程序的类似线程上,我应该看到里面的 COM 对象“DCOM 配置” tab in dcomcnfg /32
,但是我找不到任何具有相关 CLSID 的内容。我尝试跑步dcomcnfg
没有“/32”后缀,但也没有成功。我需要从中获取数据的主要应用程序是 32 位的(我们称之为母应用程序)。
有什么建议我可以如何解决这个问题吗?我将非常感激。谢谢!