2016-02-08 36 views
0

我有一個使用COM的C#.NET應用程序。Invoke-Command遠程計算機導致COMException(0x80040154)

當我在本地調用應用程序(machine1)時,應該創建COM對象。

當我遠程啓動該應用程序使用

Invoke-Command -Session $session -ScriptBlock {path\theapp.exe} 

另一機(機2)的應用程序啓動時(上當然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連接就會工作,爲什麼後來運行時會發現這個類沒有被註冊?

感謝您的任何提示和指針!

+0

您是否查找過HRESULT(0x80040154)?這是什麼告訴你的?你看過事件日誌('eventvwr.msc')嗎?這是什麼告訴你的? –

+0

事件日誌不顯示任何異常... –

回答

0

問題已解決。

原因是(1)組件的調試/發佈版本不匹配,(2)另一個組件不作爲服務運行。

感謝您的閱讀和發佈!