title: How to select .NET framework version running from Excel?
body: <p>How can I specify that Excel uses the .NET framework version 2.0 when running .NET dlls other than adding an excel.exe.config file to the Office Binary folder?</p>
  <p>Our application runs in Excel and uses VBA which makes calls into managed code in .NET assemblies.  I believe the textbook way of doing this is to add excel.exe.config to the Office binary directory containing:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
  &lt;configuration&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version=&quot;v2.0.50727&quot;/&gt;
    &lt;/startup&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>This option is not acceptable for our clients, firstly because they simply won't allow us to add files to the Office directory and even if they did we could not risk breaking some application using .NET v1.1 which is the default choice of Excel.</p>
  <p>The solution which we thought would work was to copy the Excel.exe file to our own applications directory from the client's Office directory, to add the config file there and execute that file.  It works well but we are having serious installation problems where the install script cannot find the correct version of Excel.  Plus it's a nasty kludge in the first place.</p>
  <p>Any ideas would be welcome.  I wonder if a layer of unmanaged (non .NET) code in a DLL might work.  Some advice on how to do this or some simpler alternative would be appreciated as this is non-trivial.</p>
  <h3>Related:</h3>
  <blockquote>
  <p><a href="https://stackoverflow.com/questions/436958/-net-app-config-question">.NET app.config question</a></p>
  </blockquote>