JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.63k stars 1.05k forks source link

Microsoft.Bcl.AsyncInterfaces dependency issue #2262

Closed mtissington closed 1 month ago

mtissington commented 1 month ago

Describe the bug Using CsvHelper 32.0.3 Visual Studio 2022 Professional (latest updates) 17.10.1 Built project with .NET 4.8. When attempt to use csv I get an error that Microsoft.Bcl.AsyncInterfaces or one of it's dependencies is missing. I've installed (not installed automatically) Microsoft.Bcl.AsyncInterfaces Microsoft.Bcl.HashCode

To Reproduce Build .NET 4.8 project

Expected behavior CSV should run without error and find Microsoft.Bcl.AsyncInterfaces

Is this related to #2230 ?

alexeygritsenko commented 1 month ago

I have same issue. ASP.NET 4.8 already target to Microsoft.Bcl.AsyncInterfaces 8.0.0, but CsvHelper throw error vserion 7.0.0 not found (System.IO.FileLoadException)

alexeygritsenko commented 1 month ago

@mtissington why u close topic? please write u solution

mtissington commented 1 month ago

I noticed that the issue only happened in our shipping product. The internal debug and release builds worked. Turns out we were not packaging the app.config file - once we did that it worked.

This is the contents of the config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
  </startup>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.DoNotScaleForDpiChanges=false" />
    <AppContextSwitchOverrides value="Switch.System.Windows.Controls.Grid.StarDefinitionsCanExceedAvailableSpace=true" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
alexeygritsenko commented 4 weeks ago

@mtissington thanks, it helped me! ASP.NET Web.config was missing an entry:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
JoshClose commented 3 weeks ago

I just released 33.0.0 where I bumped the version to 8.0.0.