We're hitting an issue with Microsoft.Bcl package where NuGet is adding a binding redirect for a binary that is considered part of the framework, this causes the application to crash because the binding redirect refers to assembly version that is not available at runtime.
@Repro:
1. Create a new Console Application targeting 4.5
2. Create a new Portable Library targeting .NET Framework 4.5, Silverlight 4, Windows Phone 7.5 and .NET for Windows Store apps
3. Add a reference to the portable library from the Console Application
4. Install the Microsoft.Bcl package (1.0.16-rc) to both projects
@Expected: No binding redirect for System.Runtime in the .NET Framework 4.5 project because a ___later version___ is part of the target framework (see C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\RedistList\FrameworkList.xml)
@Actual: Binding redirect
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" />
</dependentAssembly>
You can use the IVsFrameworkMultiTargeting to determine if a given assembly version is available as part of a given target framework.
Comments: Yes I'm talking about the ConsoleApplication. The binding redirects in the portable library project are expected, and do not affect runtime behavior (as the app.config is ignored and not copied to the app project), and hence can't cause an application to crash. I've found another repro (NuGet has really weird logic around when it decides to add binding redirects so it was hard to find a repro). The repro is instead of using the Microsoft.Bcl package, install the Microsoft.Net.Http, 2.2.3-beta package. Make sure you are targeting __4.5__ from the ConsoleApplication and the exact platforms that I called out above for portable.
@Repro:
1. Create a new Console Application targeting 4.5
2. Create a new Portable Library targeting .NET Framework 4.5, Silverlight 4, Windows Phone 7.5 and .NET for Windows Store apps
3. Add a reference to the portable library from the Console Application
4. Install the Microsoft.Bcl package (1.0.16-rc) to both projects
@Expected: No binding redirect for System.Runtime in the .NET Framework 4.5 project because a ___later version___ is part of the target framework (see C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\RedistList\FrameworkList.xml)
@Actual: Binding redirect
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" />
</dependentAssembly>
You can use the IVsFrameworkMultiTargeting to determine if a given assembly version is available as part of a given target framework.
Comments: Yes I'm talking about the ConsoleApplication. The binding redirects in the portable library project are expected, and do not affect runtime behavior (as the app.config is ignored and not copied to the app project), and hence can't cause an application to crash. I've found another repro (NuGet has really weird logic around when it decides to add binding redirects so it was hard to find a repro). The repro is instead of using the Microsoft.Bcl package, install the Microsoft.Net.Http, 2.2.3-beta package. Make sure you are targeting __4.5__ from the ConsoleApplication and the exact platforms that I called out above for portable.