Question

I'll explain what i'm trying to do (and why) first and then get more into the details.

I'm trying to get Registration Free COM activation working in the context of a language that is compiled JIT. I use Reg-Fre COM because i would like to avoid having to register my COM component and would like this application to be installable without administrative rights.

The JIT compiler is the main executable is signed and contains an embeded manifest. Latest versions of Windows prefer the embeded manifest over an external one, by default (it was the opposite on Windows XP). Since the JIT is signed, i cannot extract/modify/update it's manifest without breaking the signing. Also, this would introduce complexity in the maintenance of our application (always making sure we embed a new manifest). And there's are also the legal implications of modifying a program for which i don't own the rights.

So, my idea was to try to get the WinSxS activation going thru a Win32 wrapper library for which i would provide a manifest that lists the dependencies. As a proof of concept, i decided to make a simple VB6 app, a C++ Wrapper Library and two COM library (1 in .NET and 1 in VB6). The wrapper contains 3 methods, one that calls the VB6 COM, one that calls the .NET COM and one that returns a simple string. As long as everything as my COM are registered, it works, of course. If i unregister them, provide manifests for the COMs and add them as dependencies to the main executable's manifest, it works. If i unregister them, provide manifests for the COMs and the C++ Wrapper and add the com as dependencies for the C++ Wrapper and then add the C++ Wrapper as the only dependency in the main executable's manifest, it works. If i delete my main executable's manifest, the COM calls stop working but the simple string method still works.

Please note that for all my tests, i run a Powershell script that changes the Modified Date of all my files, making sure to trip the activation context cache (manifest).

From there, i started debugging using SXSTrace.exe and setting the COMPlus_LoadLogDir variable. I found out that if my manifest is external, it never gets taken into consideration. I also found out that if i embed it in the .DLL, sxstrace shows it is found, parsed and that the dependencies are found, their manifest found and i get the usual successful context activation lines in the log.

INFO: Parsing Manifest File C:\RegFreeComWrapper\bin\vbCom.MANIFEST.
INFO: Manifest Definition Identity is vbCom,type="win32",version="1.0.0.0".
INFO: Parsing Manifest File C:\RegFreeComWrapper\bin\netCom.MANIFEST.
INFO: Manifest Definition Identity is netCom,processorArchitecture="msil",version="1.0.0.0".
INFO: Activation Context generation succeeded.
End Activation Context Generation.

However, even tho the log says that, my COM calls still dont go thru. When the call goes thru for the .NET COM call, i get some output in the COMPlus_CLRLoadLogDir configured path.

In this case, i don't get any output.

As soon as i add the manifest that only lists my C++ Wrapper as a dependency to my main executable, everything starts working again. I get a similar output from SXSTrace, but now the COM call works. As mentioned, in all cases, the C++ Wrapper's simple string method works. Meaning that even tho i have no manifest from my main executable, it can still find my .dll and call it. Seems like the COMs don't work if i dont have the full manifest chain: Application.Manifest > Wrapper.Manifest > COMs manifests

So, two things here... 1. Is the thing i'm trying to do even possible? (Having dependencies listed only in the manifest of a DLL that belongs to me, without touching the main executable's manifest) 2. If it is possible, i'm probably only missing a small thing to get everything going... what is it ? :)

I can provide all my code/executable as examples, should someone be interested in trying stuff with em.

Was it helpful?

Solution

Got it working!

I modified my C++ Wrapper to use the Activation Context API and force a context activation using 'ActivateActCtx'

http://msdn.microsoft.com/en-us/library/aa374151(v=vs.85).aspx

I wrapped my code with their example's code and made sure to reference my manifests and now all is working fine. No manifest on my main executable!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top