weismat
weismat

Reputation: 7411

Could not load file or assembly Microsoft.Bcl.AsyncInterfaces

I can not use the SqlType provider due to an issue with Microsoft.Bcl.AsyncInterfaces.
I am using a minimal program with .NET 4.7.2 and F# 4.7.0.0. My Nuget packages contain a reference to:

package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net472"

Severity Code Description Project File Line Suppression State Error FS3033 The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Details: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Das System kann die angegebene Datei nicht finden. TestSqlProvider C:\Users\weism\source\repos\TestSqlProvider\TestSqlProvider\Program.fs 9 Active

What can I do to fix this issue?

Upvotes: 60

Views: 118033

Answers (13)

Todd Vance
Todd Vance

Reputation: 4711

My Entity Framework Core just needed upgraded.

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.10" /> TO <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />

Upvotes: 0

Radim D
Radim D

Reputation: 1

After uprgrade to Net 8 i got this issue. Solved by installing Microsoft.Bcl.AsyncInterfaces 8.0.0

Upvotes: 0

kcg7
kcg7

Reputation: 31

I had the similar issue. For me, it was working fine on local, but on the server(dev or QA), it was failing. My project has two solutions - One for Web and the other one is for DB Access. I resolved this issue in below ways.

  1. Found out that there is a discrepancy of Microsoft.Bcl.AsyncInterfaces - Web solution was having 5.0.0 whereas DB Access solution had 6.0.0 . I upgraded Web Solution's BCL package to 6.0.0
  2. Found that below dependentAssembly was missing from web.dev and web.qa config files even after installation of BCL interface 6.0.0 nuget package. I manually added this in both config files and it fixed the issue.

BCLInterface

Spent a good amount of time as the error was misleading and it says that the version it is looking for is 'Version=1.0.0.0'. Hope this helps. Thanks.

Upvotes: 0

Vikram Singh
Vikram Singh

Reputation: 401

For .Net Core, This problem basically occurs, when we use layered architecture. Just make sure the version of Microsoft.EntityFrameworkCore should be same in all project, wherever it is used.

Upvotes: 13

Matthew Beck
Matthew Beck

Reputation: 596

I had to restart my production server, which is also my web server for several websites, among other things. After the restart, I now have a new, different error Error NU1301: Unable to load the service index for source... What a nightmare NuGet package management is.

Upvotes: 0

Saibamen
Saibamen

Reputation: 648

I was able to fix it by removing <Private>True</Private> from csproj for Microsoft.Bcl.AsyncInterfaces. Just reinstall this NuGet package

Upvotes: 1

Dan7el
Dan7el

Reputation: 2047

Updating the Microsoft.Bcl.AsyncInterfaces assembly via NuGet did everything it needed to do, including adding the bindingRedirect entries in the appropriate config files.

I also did all the other hygienics. I cleaned my solution, deleted the bin and obj directory entries, and also cleaned my localhost deploy locations.

However, I still got this error. I reviewed the output (my application is a .NET 4.8 MVC Web application, so the web page showed the error log in detail), and I found that it was failing on loading SimpleInjector.

I updated SimpleInjector to the latest version via NuGet and that fixed my error.

Unfortunately, I didn't keep a copy of the error page, so I can't show you what I saw, but the bottom line is to examine the output or log in detail, see if you can find where the application is attempting to load the assembly that is failing, and update that assembly that appears to be calling the load.

Upvotes: 0

Der_Meister
Der_Meister

Reputation: 5007

I don't use Microsoft.Bcl.AsyncInterfaces at all in my .NET 4.8 project. Some library depends on version 1.0.0.0. I resolved the issue using a binding redirect:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

Microsoft.Bcl.AsyncInterfaces.dll 5 was copied to Bin after build.

Upvotes: 14

Chandan Dutta
Chandan Dutta

Reputation: 26

Check in your installed nuget packages--- If version of Microsoft.EntityFrameworkCore and your .net project is different then it can be a problem. Example - If EntityFrameworkCore is at v5.1.5 or higher & your project dotnet core v3.1 project, this can be the issue.

To solve,

  1. down-version Microsoft.EntityFrameworkCore to equal version of project such as v3 version. to down version click on tool in visual studio -->Nuget Package Manager--> Manage Nuget package for Solutions --> click on installed ---> select nuget package which you want to downgrade --> click on uninstall and then select the same nuget package and then install version 3.1.5 or relevent package.

or

  1. Install Microsoft.Bcl.AsyncInterfaces (Nuget package)

Upvotes: 0

Ashutosh Kumar
Ashutosh Kumar

Reputation: 91

Make sure you have unique single version of that dll. Another step would be to add a binding redirect in the app.config as told in the above comments.

Upvotes: 0

Valera
Valera

Reputation: 609

This error also happens when you try using Microsoft.EntityFrameworkCore v5 in a dotnet core v3.1 project. To resolve, down-version Microsoft.EntityFrameworkCore to latest v3 version.

Upvotes: 14

Sanushi Salgado
Sanushi Salgado

Reputation: 1436

For me, installing the Microsoft.Bcl.AsyncInterfaces (Nuget package) fixed the issue.

Upvotes: 53

Omar Nasr Saad
Omar Nasr Saad

Reputation: 39

I think you update package in one layer. for me i worked in project with three layers (api, AdminTool, Data) the AdminTool Layer had a reference to Data Layer i updated all packages in AdminTool only so i had this error i update package also in data layer and api layer so the problem solved. I hope that help you.

Upvotes: 3

Related Questions