Send mail to the author(s)

August 12, 2008

HOWTO: Prevent ResolveAssemblyReferences warnings in Visual Studio 2008

When you reference an assembly compiled against .NET Compact Framework 2.0 in a project targeting .NET Compact Framework, it's quite likely you will receive a number of ResolveAssemblyReferences warnings, similar to this:

ResolveAssemblyReferences:
  Consider app.config remapping of assembly "System.Windows.Forms, Culture=neutral, 
  PublicKeyToken=969db8053d3322ac, Retargetable=Yes" from Version "2.0.0.0" [] to 
  Version "3.5.0.0" [C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\
  WindowsCE\System.Windows.Forms.dll] to solve conflict and get rid of warning.

This warning occurs when the compiler has loaded the .NET Compact Framework 3.5 base class libraries (BCLs) and the referenced assembly, but the metadata contained in the referenced assembly references the .NET Compact Framework 2.0 BCLs.

To remove the warnings you can add an App.Config to your project and redirect the assembly bindings from the 2.0 versions to the 3.5 equivalents. Below is an example of the XML required in the App.Config to redirect the 2.0 version of System.dll to the 3.5 version.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentassembly>
        <assemblyidentity name="System" culture="neutral" publickeytoken="969db8053d3322ac" />
        <bindingredirect  newVersion="3.5.0.0" oldVersion="2.0.0.0" />
      </dependentassembly>
    </assemblybinding>
  </runtime>
</configuration>

You will need to add a dependentassembly element for each of the ResolveAssemblyReferences warnings that you receive.

Make sure the Build Action property of the App.Config is set to Content and the Copy To Output Directory property is set to Only if newer. Then, rebuild your solution and the warnings should not appear.

Comments are closed.