Search code examples
c#.netassemblies.net-framework-version

How to integrate Matlab producing dll with .net?


I am trying to integrate Matlab producing dll with my .net project when I call make its object it gives the below error.

Error 1 Could not load file or assembly 'ChordRecognizerDotNETAssemplyForTuning' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I have installed MCR and frameworks till 4.0 as you can see in pic. please help

enter image description here


Solution

  • Place this in your main projects app.config file

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

    useLegacyV2RuntimeActivationPolicy should do the trick.

    And don't forget to set your target framework to ".NET Framework 4" rather than ".NET Framework 4 Client Profile"