question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not load file or assembly 'Microsoft.Data.SqlClient, Version=1.13.20136.2

See original GitHub issue

Describe the bug

When making a database call with Microsoft.Data.SqlClient it is looking for the wrong version.

This application uses a combination of EntityFramework Core 3.1.9 and Microsoft.Data.SqlClient 2.0.1 calls.

Error Msg:Could not load file or assembly 'Microsoft.Data.SqlClient, Version=1.13.20136.2, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).

Stack Trace:(no main stack trace available)

Expected behavior

I expected it to use the 2.0.1 version that is used and distributed with the application.

Further technical details

Microsoft.Data.SqlClient version: (found on the nuget or Microsoft.Data.SqlClient.dll) .NET target: (e.g. Framework 4.8) SQL Server version: (e.g. Azure SQL) Operating system: (e.g. Windows 10)

Additional context I have checked the entire solution and the only references I see are to Microsoft.Data.SqlClient 2.0.1 so I am not sure where it is getting this 1.13.20136.2 from. I have tried binding redirects with the following, which appears to be working but may be wrong (what is the best way to get the version needed here?).

<dependentAssembly> <assemblyIdentity name="Microsoft.Data.SqlClient" publicKeyToken="23ec7fc2d6eaa4a5" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.0.0" /> </dependentAssembly> Not sure what to try next so hoping someone can put me on the path to understanding why it thinks it needs this old version. We use directory.build.targets for our nuget packages in this solution and in searching the solution there is no reference to any earlier version of Microsoft.Data.SqlClient.

Thank you in advance for any insight or suggestions.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
wjviicommented, Dec 2, 2020

Let me give it a try.

0reactions
JRahnamacommented, Dec 3, 2020

Beside ildasm or ilspy added in your visual studio you can use powershell. Basically, what you need to do is, install the package by Install-Package -Name "Microsoft.Data.SqlClient" -Destination ".\temp" -Force -Source MyNuget -SkipDependencies This will isntall the package in a folder named temp, created in the same directory. MyNuget can be defined as name variable for your provider or source. You can get list of your providers by running Get-PackageProvider after installing the package you can run: Get-ChildItem *.dll -Path .\temp -Recurse | ForEach-Object versioninfo

That will provide you a list like this:

image

in the FileVersion section you can find assembly versions.

The other option would be using NuGet Package Explorer and clicking on DLLs: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found