An exception of type 'System.MissingMethodException' occurred in System.Collections.Concurrent.dll
Often when I work on blog posts, I use the source code from an old blog as the basis of a new one.
A few days I downloaded one of my zip files with an example showing how to use Entity Framework with SQL Server in a Docker container. Spun up Docker and hit F5 on my application, and got -
Exception has occurred: CLR/System.MissingMethodException An exception of type 'System.MissingMethodException' occurred in System.Collections.Concurrent.dll but was not handled in user code: 'Method not found: 'System.IServiceProvider
I was sure that the code worked when I wrote it, I am careful about those things.
A little binging/googling didn’t help.
But in my .csproj file, I had this -
<ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"/> </ItemGroup>
I must have accidentally removed the version number while working on the file months earlier.
The fix was to remove the line and add the package back in with the version number -
<ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" /> </ItemGroup>
- Dependency Injection of an Entity Framework Context within Program.cs Using Top Level Statements
- Sending MediatR Notifications Immediately After Saving an Entity with Entity Framework Core
- Turning off Tracking for Find and FindAsync in Entity Framework
- Accessing Objects Just After they are Saved by Entity Framework
- Dependency Injection with the Lambda Annotations Library for .NET - Part 2, Lambda Functions