I have (source code) a mixed-mode (.NET 2.0) DLL-assembly that is a TAPI telephony service provider. So it is loaded by the Windows Telephony Service (svchost). This works as expected in Windows XP, Vista and Windows 7 when .NET 2.0 or 3.5 is (pre)installed.
Now I am targeting Windows 8 with .NET 4 preinstalled. The problem I am faceing is that Windows will not load the DLL (and TSP) with that configuration. When I install .NET 3.5 everything works fine but I'd rather not like to force users to install .NET 3.5 in addition to .NET 4 already present.
I allready read What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project? but this does not apply because I do not have an application and thus no app.config file.
According to http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/ it seems to be an interesting approach to setup the useLegacyV2RuntimeActivationPolicy
before loading the mixed-mode assembly. But I guess this will not work in my case because the assembly is loaded by the telefony service.
Or is this possible in the mixed-mode assembly itslef? The assembly is always invoked by unmanaged calls from the Windows service. Is it possible in such a call to set the policy in the unmanaged code part before creating the first gcroot
or is this already too late? If it's possible, how would I obtain and call the required COM object to do so?