views:

184

answers:

1

I had to migrate a .NET 3.5 to 4.0 but some dll's were not loading, after googling I found that creating an app.config would solve it:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

I would like to setup these options without using configuration files, is it possible?

A: 

It is technically possible. You'd have to host the CLR yourself so you can call the ICLRRuntimeInfo::BindAsLegacyV2Runtime() method before you create the primary AppDomain. A .config file would normally be a much lower pain point unless you are already hosting.

Hans Passant
You're right, I will stick with app.config, however I found what you said interesting, do you know where I could find information about writing a custom host for the CLR?
Thiado de Arruda
Hans Passant