我想使用未註冊的系統或用戶範圍的特定版本的ActiveX組件。如果我使用清單文件,一切都按預期工作。但是,嵌入式清單僅適用於C++客戶端代碼。如何從C#等託管代碼中爲ActiveX組件使用嵌入式免註冊清單?
這裏是依賴聲明
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="MapWinGIS.ocx" version="4.9.1.0" />
</dependentAssembly>
</dependency>
如果我使用SxStrace,我看到下面的
INFO: Parsing Manifest File C:\OSGeo4W\bin\TestApplication.exe.
INFO: Manifest Definition Identity is MyApplication.app,version="1.0.0.0".
INFO: Reference: MapWinGIS.ocx,type="win32",version="4.9.1.0"
INFO: Resolving reference MapWinGIS.ocx,type="win32",version="4.9.1.0".
INFO: Resolving reference for ProcessorArchitecture MapWinGIS.ocx,type="win32",version="4.9.1.0".
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\OSGeo4W\bin\MapWinGIS.ocx.DLL.
INFO: Attempt to probe manifest at C:\OSGeo4W\bin\MapWinGIS.ocx.MANIFEST.
INFO: Attempt to probe manifest at C:\OSGeo4W\bin\MapWinGIS.ocx\MapWinGIS.ocx.DLL.
INFO: Attempt to probe manifest at C:\OSGeo4W\bin\MapWinGIS.ocx\MapWinGIS.ocx.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference MapWinGIS.ocx,type="win32",version="4.9.1.0".
ERROR: Activation Context generation failed.
所以它顯然只是想DLL不管。問題是我從AxImp獲得的DLL沒有嵌入式清單。有沒有一種很好的方式來使用嵌入式清單?我覺得我可以嘗試將mt嵌入到我從AxImp中獲得的DLL中,但這看起來很詭異。
P.S.我不確定是否將ocx重命名爲dll是一種很好的方法,因爲AxImp也會爲COM東西生成相同的名稱DLL,並且看起來好像沒有標記可顯式爲COM CLR代理提供輸出名稱。
'comClass'條目被嵌入到OCX資源中的清單中。僅在C++客戶端的清單中具有依賴關係就足夠了。在EXE中放置一個帶TLB的清單似乎有點奇怪。會嘗試,但我想應該工作。儘管第二段和第三段我都有點失落。如果OCX被註冊,爲什麼我會關心'Isolated'?如果我設置了'Isolated',爲什麼我會將具有TLB內容的清單從OCX複製到CLR EXE中。我不介意在開發機器上註冊,但不在部署上註冊。 – mlt
您關心的是* *未註冊時的隔離。在部署機器上。它只需要在您的開發機器上註冊,以便清單條目可以自動確定。就像你用mt.exe做的那樣 –
我是否只是將生成的清單文件添加到項目中以便嵌入?另外奇怪的是,只有當OCX本身被添加爲參考時才能設置'Isolated'。這樣就不能傳遞類似'tlbimp'等選項,例如命名空間。 – mlt