0

I am trying to make a COM for my old project. The COM is built successfully, but when I tried to use the COM to call some functions, this error comes out:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

The old project have some parts in .NET 4.0, and some parts in .NET 3.5. Though I tried to make all parts in .NET 4.0, some third party DLLs I used cannot be rebuilt to higher framework.

I have searched this problem, and all people told me to add a app.config or web.config to the application that:

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku='.NETFramework,Version=v4.0' />
    <requiredRuntime version="v4.0.30319" />
  </startup>

This will work when form or server calling. But my COM may be called by vbs like:

Dim obj
Set obj = CreateObject("ClassLib.Class1")
msgbox obj.add(3,5)

In this case, I can't add that config file to the vb file. Is there any solution fot this?

Flysword
  • 13
  • 4
  • Don't you think people meant that you should add this app.config to your old project and rebuild with that? – Kobor42 Oct 16 '13 at 17:40
  • Technically you can give the VBScript interpreter that .config file as well. It doesn't scale very well. The only true fix is to get this mixed-mode assembly built to target 4.0 or to go back to 3.5 – Hans Passant Oct 16 '13 at 19:04

0 Answers0