对远程机器的Invoke-Command导致COMException(0x80040154)

时间:2016-02-08 17:04:52

标签: c# powershell com invoke-command

我有一个使用COM的C#.NET应用程序。

当我在本地调用应用程序(machine1)时,将按原样创建COM对象。

当我使用

从另一台机器(machine2)远程启动应用程序时
Invoke-Command -Session $session -ScriptBlock {path\theapp.exe}

应用程序启动(当然是在machine1上)但无法绑定COM对象:

 System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {C4DBE1C1-0608-48DF-AD9D-F34284FE7040} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
   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)

我不明白这是怎么可能的 - 因为如果在本地启动执行COM连接有效,为什么运行时会发现该类没有注册?

感谢任何提示和指示!

1 个答案:

答案 0 :(得分:0)

问题解决了。

原因是(1)组件的调试/发布版本不匹配,以及(2)另一个组件不应该作为服务运行它应该具有。

感谢阅读和发帖!

相关问题