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:
- Unload and reload project
- Clean and rebuild solution
- Delete obj and bin folder and rebuild solution once again
Someone know how to solve this issue?
2
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
Add this line to your project:
It helped me.