我想使用未注册的系统或用户范围的特定版本的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