Could not load file or assembly System.Data.SqlClient, Version=4.2.0.2 when I use System.Data.SqlClient Version 4.4.3

后端 未结 6 2014
夕颜
夕颜 2021-01-07 17:10

I use System.Data.SqlClient Version 4.4.3 for all .NET Standard 2.0 class libraries in my ASP.NET Core 2.0 project. Why do I get

Cou

相关标签:
6条回答
  • 2021-01-07 18:01

    For me, the solution was removing the System.Data.SqlClient package and installing it again. Doing the upgrade of the package wasn't sufficient.

    0 讨论(0)
  • 2021-01-07 18:07

    I got the same issue, SerializationException with message:

    Unable to find assembly 'Microsoft.Data.SqlClient,  
    March 3rd 2020 16:36:46Error
    Version=1.0.19269.1, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'
    

    but everything is ok with dll, issue was caused by invalid connection string, it takes me almost few hours to figure out what happens!

    0 讨论(0)
  • 2021-01-07 18:09

    Don't know whether this is the same situation that I faced. I added System.Data.SqlClient via nuGet and it worked fine.

    0 讨论(0)
  • 2021-01-07 18:12

    This happens when some dependent assembly uses old version of same library. To solve that you can use assembly redirecting, to force old library use newer version.

    put this in your app.config or in web.config in case of asp.net

    <dependentAssembly>  
        <assemblyIdentity name="System.Data.SqlClient"  publicKeyToken="b03f5f7f11d50a3a"  culture="neutral" />  
        <bindingRedirect oldVersion="4.2.0.2" newVersion="4.4.3.0" />  
    </dependentAssembly>  
    
    0 讨论(0)
  • 2021-01-07 18:13

    Downgraded to

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
    

    and everything works again! Lost 4 hours today!!!

    0 讨论(0)
  • 2021-01-07 18:16

    I had a similar issue to this today, I updated a number of packages including the All meta-package to 2.0.6. My app then wouldn't work quoting the error above. After a lot of investigation I did the following and it now seems to be working.

    Connect to the Azure Web Site using FTP, navigate to the site -> wwwroot folder. Here I had a folder called "refs" and another called "runtimes". I deleted both of these folders (after taking a local backup), re-published my app and it worked!

    Not sure why it worked but I thought this might be useful is someone stumbles across this with a similar issue.

    0 讨论(0)
提交回复
热议问题