title: use .net 2.0 dll in .net 4.5 project (vshost crashes on debug)
body: <p>I am trying to use a dll file created from matlab with the dotnetbuilder (<a href="http://www.mathworks.se/help/dotnetbuilder/ug/create-a-net-component-from-matlab-code.html" rel="nofollow">http://www.mathworks.se/help/dotnetbuilder/ug/create-a-net-component-from-matlab-code.html</a>)..</p>
  
  <p>In order to use the dll, I have to add a refference to a matlab dll called 'MWArray.dll' (<a href="http://www.mathworks.se/help/dotnetbuilder/ug/integrate-your-net-component-in-a-c-application.html" rel="nofollow">http://www.mathworks.se/help/dotnetbuilder/ug/integrate-your-net-component-in-a-c-application.html</a>), and sadly this dll only seem to be available for .net 2.0.</p>
  
  <p>The only way I've been able to make a simple console application work with the dll I created from matlab, was by doing following:</p>
  
  <ul>
  <li>target the dll for .net 2.0 when building it in matlab with
  dotnetbuilder. </li>
  <li>change the version of .net used in my console
  application to version 2.0</li>
  </ul>
  
  <p>If I don't do this, the console application will crash vshost.exe when I try to run the project.</p>
  
  <p>I wish to be able to use .net 4.+ features, so configuring the project to use .net 2.0 is not acceptable.. And when I get this simple console application running with at least .net 4.0, I will try to get it working in an F# 3.0 application as well.</p>
  
  <p>My program looks like this:</p>
  
  <pre><code>...
  using MathWorks.MATLAB.NET.Arrays;
  using makesquare;
  
  namespace Matlabski
  {
      class Program
      {
          static void Main(string[] args)
          {
              try
              {
                  var stuff = new makesquare.MLTestClass();
                  var res = stuff.makesquare(1, 3);
                  Console.WriteLine(res[0]);
                  Console.WriteLine("sdfsdf");
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>and I have attempted to edit the app.config file to be able to handle both .net 2 and 4:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;startup useLegacyV2RuntimeActivationPolicy="true"&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/&gt;
      &lt;supportedRuntime version="v2.0"/&gt;
    &lt;/startup&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>But it doesn't work..</p>
  
  <p><strong>Is it possible to setup the project such that I can use both .net 2.0 and 4.5, and will this make my project work?? or do I have to do something else to use this annoying .net 2.0 dll..?</strong></p>
  
  <p>I am using:</p>
  
  <ul>
  <li>VS2013</li>
  <li>MATLAB R2013b (64bit)</li>
  </ul>