I have a C#.NET application that uses COM.
When I call the application locally (machine1), the COM object is created as it should.
When I start the application remotely from another machine (machine2) using
Invoke-Command -Session $session -ScriptBlock {path\theapp.exe}
the application starts up (on machine1 of course) but fails to bind the COM object:
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)
I do not understand how this is possible -- since the COM connection works if execution is started locally, why would the runtime find out later that the class is not registered?
Thanks for any hints and pointers!
Problem solved.
Reason was (1) a mismatch of debug/release versions of components and (2) another component not run as service wehen it should have.
Thanks for reading and posting!