skip to Main Content

The error description is as below:

Severity Code Description Project File Line Suppression State

Error CS0433 The type ‘ServiceCollection’ exists in both ‘Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’ and ‘Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60’

I am having this error suddenly, I had tried several steps but the error wont go off.
Some steps that I had tried:

  1. Unload and reload project
  2. Clean and rebuild solution
  3. Delete obj and bin folder and rebuild solution once again

Someone know how to solve this issue?

Error Image

2

Answers


  1. The comment on the original post was really helpful

    I had the same issue and managed to resolve it by targeting .NET 6.0

    Probably best to ready ourselves to point all of our .NET 5.0 projects to .NET 6.0 anyway since .NET 5.0 is being deprecated

    Login or Signup to reply.
  2. Add this line to your project:

    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
    

    It helped me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search