I have written a class library in C# (mydll.dll) which accesses a third party dll (3rdpdll.dll). Mydll.dll, in turn gets consumed via COM interop by a non-.NET process (myapp.exe).
Mydll.dll is .NET 4.0 but 3rdpdll.dll has been built using v2.0.50727, so when I run myapp.exe, I get the following error:
Mixed mode assembly is built against version ‘v2.0.50727’ of the
runtime and cannot be loaded in the 4.0 runtime without additional
configuration information…
This gets fixed if I create a file called “myapp.exe.config” next to myapp.exe containing the following XML:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Problem is myapp.exe gets updated a lot and contains version information in the name, such as myapp.v2.063.exe. This would require the config file to be renamed with every new iteration of the app (myapp.v2.063.exe.config
).
Is there a way for me to declare a static name for the config file, such as “app.config” so that it does not need to be renamed and reshipped along with every new iteration of myapp.exe? Or better yet, could I hard-code the useLegacyV2RuntimeActivationPolicy attribute in mydll.dll so that I can avoid using a config file altogether?
I went with Joe‘s idea: