1

I'm Trying to integrate Matlab with C# I made a small prog. to apply average filter
on an image but an error appears to me on this line of code

Bitmap Array2Image(MWNumericArray num)
    {
        **double[,] array = (double[,])num.ToArray();**...... return bmp;
    }

the error: 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.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Moataz Amer
  • 109
  • 2
  • 11

1 Answers1

1

See here; What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

In order to use a CLR 2.0 mixed mode assembly, you need to modify your App.Config file to include:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

The key is the useLegacyV2RuntimeActivationPolicy flag. This causes the CLR to use the latest version (4.0) to load your mixed mode assembly. Without this, it will not work.

Note that this only matters for mixed mode (C++/CLI) assemblies. You can load all managed CLR 2 assemblies without specifying this in app.config.

Community
  • 1
  • 1
Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144