title: ASP.NET Web Application Using .NET Standard Library
body: <p>I'm just getting started with .NET Standard, and I'm trying to grasp best practices in this new scenario.  I've transitioned a few of my key libraries to .NET Standard 2.0.  When I make a new Web application (ASP.NET 4.6.1, 4.6.2, or 4.7) project, add my new libraries as references, and then build, I get lots of warnings.  None of these warnings are shown if the library targets .NET Standard 1.4 or earlier, but I need .NET Standard 2.0.  This is a portion of those warnings:</p>
  
  <pre><code>Consider app.config remapping of assembly "System.Runtime.Serialization.Xml, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.10.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.Serialization.Xml.dll] to Version "4.1.3.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\\net461\ref\System.Runtime.Serialization.Xml.dll] to solve conflict and get rid of warning.
  ... [About 50 similar lines] ...
  Consider app.config remapping of assembly "System.Runtime.InteropServices.RuntimeInformation, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "0.0.0.0" [] to Version "4.0.2.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\\net461\ref\System.Runtime.InteropServices.RuntimeInformation.dll] to solve conflict and get rid of warning.
  </code></pre>
  
  <p>The very last warning I get is this:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file:
  &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;&lt;dependentAssembly&gt;&lt;assemblyIdentity name="System.Runtime.Serialization.Xml" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /&gt;&lt;bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" /&gt;&lt;/dependentAssembly&gt;&lt;/assemblyBinding&gt;
  ... [About 50 similar lines] ...
  &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;&lt;dependentAssembly&gt;&lt;assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /&gt;&lt;bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /&gt;&lt;/dependentAssembly&gt;&lt;/assemblyBinding&gt;
  </code></pre>
  
  <p>If I double-click that warning, it adds the appropriate binding redirects to my Web.config file.  But I'm wondering the following:</p>
  
  <ol>
  <li><p>Am I doing something wrong?  It's hard for me to believe that adding all these binding redirects is expected for a .NET Framework 4.6.1 application to reference a .NET Standard library.</p></li>
  <li><p>Why is this all this binding redirection necessary?  Why can't my Web application just use the same assemblies the .NET Standard library is using without binding redirects?  Why does my Web application default to using old versions of these assemblies?</p></li>
  <li><p>Possibly related to this issue is that my application can start (with or without binding redirects) but quickly fails when I try to use SqlClient:  "Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."  This exception is thrown within a library that is using System.Data.SqlClient 4.4.  I tried to add this binding redirect, but it hasn't helped:  <code>&lt;dependentAssembly&gt;&lt;assemblyIdentity name="System.Data.SqlClient" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/&gt;&lt;bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0"/&gt;&lt;/dependentAssembly&gt;</code>  I later discovered that if I intentionally add the System.Data.SqlClient NuGet package to the ASP.NET project and add a binding redirect to the ASP.NET project's Web.config, the SQL operation can execute.  (The binding redirect looks like this:  <code>&lt;dependentAssembly&gt;&lt;assemblyIdentity name="System.Data.SqlClient" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/&gt;&lt;bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.2.0.0"/&gt;&lt;/dependentAssembly&gt;</code>  Even though I added the 4.4 NuGet package, when I build, 4.2 is output to the bin directory.  I don't know why it would do that, but if it would output 4.4, I don't think the binding redirect would be necessary.)</p></li>
  </ol>