Ever since we started upgrading some of our projects to .NET framework 4.0, I've been running into a lot of issues regarding the following error:
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
It's now happening with our installer application. The installer goes through a list of DLL's and installs the necessary ones on a target machine. Each assembly is loaded into context using
Assembly.LoadFile
The first assemblies in the queue are 3.5. Once the installer picks up a 4.0 DLL and tries to load it using Assembly.LoadFile, I get that error. It seems as though loading the first DLL sets the precedent as to which "runtime" is currently loaded.
Is there a way I can unload this currently loaded runtime before processing a 4.0 DLL in order to avoid this error?