This issue is related to VS2010's multi-targeting feature, which was first introduced with VS2008 and .NET Framework 4.0.
With the past few releases of Visual Studio, each Visual Studio release only supported a specific version of the .NET Framework. For example, VS 2002 only worked with .NET 1.0, VS 2003 only worked with .NET 1.1, and VS 2005 only worked with .NET 2.0.
Starting with VS 2008, MS supported the "multi-targeting" feature, which means that Visual Studio now supports targeting multiple versions of the .NET Framework, and developers are able to take advantage of the new features Visual Studio provides without having to always upgrade existing projects and deployed applications in order to use a new version of the .NET Framework library.
Now when you open an existing project or create a new one with VS 2008, you can choose which version of the .NET Framework to work with, and the IDE will update its compilers and feature-set to match this. Among other things, this means that features, controls, projects, item-templates, and assembly references that do not work with that version of the framework will be hidden, and when you build your application, you'll be able to take the compiled output and copy it onto a machine that only has an older version of the .NET Framework installed knowing that the application will work.
When Symphony MS compiler support extended to VS2010, this feature became a little tricky because there are some default behavior changes between VS2008 & VS 2010. VS2008, by default, can pick up the correct dependency libraries even though a C# binary uses a higher version of .NET Framework than its dependent libraries; VS2010, by default, does not do it for .NET 4.0.The details follow.
Not only 64bit, but when you open the 32bit C# sample with VS2010 in a host where only .NET Framework 4.0 is installed, there will be a dialog to show the multi-target issue. The reason is on this host, only .NET Framework 4.0 is installed, regardless of whether the Framework comes from the separate Framework install package or from the VS2010's built-in package.
Visual Studio 2010 includes only .NET Framework 4.0. To target earlier versions of the .NET Framework, you must have the .NET Framework 3.5 Service Pack 1 (SP1) installed. The .NET Framework 3.5 SP1 includes .NET Framework 2.0, .NET Framework 3.0, and .NET Framework 3.5. On this host, we will only see the dialog shown below.
For .NET Framework 4.0, when the target execute binary has an earlier version dependency, like Symphony SDK Platform.Symphony.Soam.Net.dll that is built from .NET Framework 2.0, the following exception will happen during runtime:
Could not load file or assembly 'Platform.Symphony.Soam.Net_64.dll' or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
The workaround is to add an optional attribute named "useLegacyV2RuntimeActivationPolicy" into a config file. If we choose .NET Framework 4.0 as the target framework to build the binaries, the {exename}.config file will be generated automatically by VS2010, e.g., SyncClient.exe.config; we can then add the attribute to it. For example:
If a host has .NET Framework 3.5 or other earlier version (like 2.0, 3.0) installed, the multi-target setting will look like the following:
If we choose to build with .NET Framework 4.0, since Symphony SDK Platform.Symphony.Soam.Net.dll is built from .NET Framework 2.0. the following exception will happen during runtime:
Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information at Platform.Symphony.Samples.SyncClient.Main(String[] args)
The workaround is to add an optional attribute named "useLegacyV2RuntimeActivationPolicy" into a config file. If we choose .NET Framework 4.0 as the target framework to build the binaries, the {exename}.config file will be generated automatically by VS2010, e.g., SyncClient.exe.config; we can then add the attribute to it. For example:
<?xml version="1.0"?><configuration><startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0"sku=".NETFramework,Version=v4.0"/></startup></configuration>
If you choose .NET Framework 2.0, 3.0, or 3.5 to build our sample with VS2010, no extra config file needs to be updated.
For VS2008, since it only supports to 3.5 SP1, you do not encounter this issue even though we select multiple versions of the .NET Framework.
Multiple targeting overview: http://msdn.microsoft.com/en-us/library/bb398197.aspxTroubleshooting .NET
Framework Targeting Errors: http://msdn.microsoft.com/en-us/library/cc668079.aspxHow to: Target a Specific
.NET Framework Version or Profile: http://msdn.microsoft.com/en-us/library/bb398202.aspx
<startup> Element: http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx