How to use the built-in registration manifest for an ActiveX component from managed code such as C #?

I would like to use a specific version of the ActiveX component that is not registered on the system or around the world. Everything works as expected if I use manifest files. However, the inline manifest only works for C ++ client code.

Here is the dependency declaration

<dependency> <dependentAssembly> <assemblyIdentity type="win32" name="MapWinGIS.ocx" version="4.9.1.0" /> </dependentAssembly> </dependency> 

If I use SxStrace, I see the following

 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. 

So, apparently, he just wants a DLL, no matter what. The problem is that the DLL obtained from AxImp does not have a built-in manifest. Is there a good way to use the inline manifest? I feel like I can try to have mt embed it in the DLL I get from AxImp, but it seems hacky.

PS I'm not sure if renaming ocx to dll is a good approach, since AxImp also generates the same DLL names for COM content, and it seems that the flags do not explicitly provide the output name for the COM CLR proxy.

0
clr interop com com-interop
source share
2 answers

There are no important entries in the manifest, such as <comClass> . That is why you see that Windows continues to search for another manifest to find what it needs. The workaround you found is not so good, it puts the manifest entries in the wrong file. It must enter the manifest manifest.

The smart way to do this is to simply let the build system take care of it. Register .ocx and simply set the Isolated property of the link to True. This will force the build system to read the required manifest entries from the registry and merge them into the application manifest.

If you do not want to leave the registered .ocx for some reason, do it only once. Locate the .manifest file in the assembly directory. Open it with a text editor and copy / paste the entries into your application manifest. Beware that this can cause the Hell DLL, if you upgrade the COM server, your manifest will be deprecated. It is always difficult to fix the problem, as it will happen in a year or two and probably with a programmer who does not know what you did.

+2
source share

Well ... the trick with

 regsvr32 MapWinGIS.ocx AxImp MapWinGIS.ocx mt -inputresource:MapWinGIS.ocx;#2 -outputresource:MapWinGIS.dll;#2 regsvr32 /u MapWinGIS.ocx 

worked for me. Although it does not seem neat. Is there a way without copying the built-in manifest to the CLR proxy and intermediate registration?

0
source share

All Articles