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>

Problem solved!

comments powered by Disqus

Related