Does anyone know why a C# created COM library that was compiled under CLR2 (.Net 3.5) doesn’t work when used with only CLR4(.Net 4)? What is missing in CLR4 that is in CLR2 for COM?
We are using the appropriate startup in the app.config to have the C# run under CLR4/.Net 4:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
All the C# stuff works until it try’s to create our COM interface. It provided the following exception:
Failed to load the runtime. (Exception from HRESULT: 0x80131700)
We get the same issue when we try to create the COM interface from C++.
Once we install CLR2 (.Net 3.5) all the COM stuff starts working. We would like to know what’s going on.
After compiling the assemblies in .NET 4, you’ll probably need to use regasm.exe to update the RuntimeVersion. If recompiling is not an option, you could potentially change the RuntimeVersion in the registry from v2.0.50727 to v4.0.30319. This worked for me. I found a similar answer here: Using a .NET-2.0-targeted COM DLL in the GAC on a .NET-4-only system