app.config with unmanaged EXEs

We have an unmanaged exe that pulls in a DLL that has some managed C++ in it.  It turns out that running our app on a system with both .NET 1.1 and .NET 2.0 results in .NET 2.0 being loaded and that is causing our app to crash with an exception code 0xE0434F4D with an HRESULT of 0x800703E6.  I tried creating a foo.exe.config file for our unmanaged exe but it doesn't seem to work.  Here is what the file contains:

< xml version="1.0" encoding="utf-8" >
<configuration>
  <startup>
   <requiredruntime version="v1.1.4322" />
  </startup>
</configuration>

However I suspect that unmanaged EXEs can't take advantage of app.config files in the first place. Can anybody shed some light on this situation.


Answer this question

app.config with unmanaged EXEs

  • MarkFred

    OK after a bit more digging it seems there are a couple of problems with my first attempt.  First and foremost <requiredRuntime> is meant only for assemblies built against .NET 1.0.  We built against .NET 1.1 so I really need to use <supportedRuntime>.  Second, XML is case-sensitive and I used <requiredruntime> instead of <requiredRuntime>.  Doh!
  • Sahil Malik

    Nevermind. It seems to work now that I removed the encoding="utf-8" and switched to supportedRuntime.  Here's what seems to work:

    < xml version ="1.0" >
    <configuration>
      <startup>
        <supportedRuntime version="v1.1.4322" />
      </startup>
    </configuration> 

    Go figure.

  • app.config with unmanaged EXEs