The type 'ServiceCollection' exists in same dependencies but in different version

Viewed 824

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

1 Answers

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

Related