title: accessing .net2.0 dll in a .net 4.0 dll
body: <p>I want to load a .NET 2.0 dll in my .Net4.0 <strong>dll</strong>. I did search for the solution and found the 'useLegacyV2RuntimeActivationPolicy' attribute that I can add to my app.config as in this url : <a href="https://stackoverflow.com/questions/4018924/mixed-mode-assembly-is-built-against-version-v1-1-4322">Mixed mode assembly is built against version &#39;v1.1.4322&#39;</a> </p>
  
  <p>But the problem for me is that, in my case, I am trying to use the .net2.0 dll in my <strong>4.0 DLL and not in an 4.0 exe</strong>. The reason is this 4.0 dll is then used in Excel as an automation add-in.</p>
  
  <p>Currently, when I acccess my .NET 4.0 API (which loads the 2.0 dll for a feature ) from Excel, I get the 'mixed mode 2.0 dll cannot be loaded in 4.0 runtime' which is understandable since COM has loaded the 4.0 CLR and hence cannot load the 2.0 dll.</p>
  
  <p>Somehow I need to make my 4.0 DLL to load the 2.0 runtime. I tried adding a app.config to the 4.0 dll but I guess only .exe reads the app.config by default to load the clr. 
  This is what I have in my app.config in the project of 4.0 dll but no use.</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.0"/&gt;
    &lt;/startup&gt;
    &lt;runtime&gt;
      &lt;NetFx40_LegacySecurityPolicy enabled="true"/&gt;
    &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>How do I solve this problem to enable my <strong>.NET 4.0 DLL</strong> to use .NET 2.0 dll ? </p>
  
  <p>Thanks,
  Mani</p>