'IServiceCollection' does not contain a definition for 'AddApiVersioning'

See original GitHub issue

I tried to add ApiVersioning in ConfigureServices() method but got an error: 'IServiceCollection' does not contain a definition for 'AddApiVersioning' and no accessible extension method 'AddApiVersioning' accepting a first argument of type 'IServiceCollection' could be found...

Tried to install package Microsoft.AspNetCore.Mvc.Versioning 3.1.1 get new error:

Version conflict detected for Microsoft.AspNetCore.Authentication.Abstractions. Install/reference Microsoft.AspNetCore.Authentication.Abstractions 2.2.0 directly to project TM.DataCollector to resolve this issue. 
 TM.DataCollector -> Microsoft.AspNetCore.Mvc.Versioning 3.1.1 -> Microsoft.AspNetCore.Mvc.Core 2.2.0 -> Microsoft.AspNetCore.Authorization.Policy 2.2.0 -> Microsoft.AspNetCore.Authentication.Abstractions (>= 2.2.0) 
 TM.DataCollector -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.AspNetCore.Authentication.Abstractions (>= 2.1.1 && < 2.2.0).	TM.DataCollector	C:\Users\Matej\Dropbox (HSI)\Development\InproTelemetrija\TM v.2\Solutions\TM.DataCollector\TM.DataCollector.csproj	1	

Using .Net Core 2.1.1 What am i missing?!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
commonsensesoftwarecommented, Jan 8, 2019

You won’t be able to use 3.1+ on ASP.NET Core 2.1 as it specifically targets 2.2. You probalby want to go back to 3.0. The only real difference between 3.0 and 3.1 is that 3.0 still targets 2.0, which allows you to use any version of ASP.NET Core 2.0+. 3.1 adds support for the Endpoint Routing feature in ASP.NET Core 2.2. To use this feature, you obviously need to use 2.2+.

The two easily solutions are:

  1. Go back to API Versioning 3.0 (if you don’t need Endpoint Routing, the features are the same as 3.1)
  2. Update ASP.NET Core to 2.2

I hope that helps.

0reactions
OneGenkiGirl73commented, Apr 16, 2020

I’m sorry, I meant to say the .GetService isn’t working as it does with the other database controller I built on my other dev machine. I’m just wondering why the behavior would be different on the other machine with the exact same code…?

Sent from Yahoo Mail on Android

On Wed, Apr 15, 2020 at 9:39 PM, Chris Martineznotifications@github.com wrote:

Sounds like something else is awry. Are you saying if you remove the call to services.AddApiVersioning(), then things work as normal?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - iServiceCollection' does not contain a definition for ' ...
Solution: AddVersionedApiExplore lives in Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer NuGet package.
Read more >
'IServiceCollection' does not contain a definition for ...
I tried to add ApiVersioning in ConfigureServices() method but got an error: 'IServiceCollection' does not contain a definition for ' ...
Read more >
AddVersionedApiExplorer Extension missing · Issue #330
Error CS1929 'IServiceCollection' does not contain a definition for 'AddVersionedApiExplorer' and the best extension method overload ...
Read more >
Fix: IServiceCollection does not contain a definition ... - YouTube
Fix: IServiceCollection does not contain a definition for 'AddDefaultIdentity' and no accessible extension method 'AddDefaultIdentity' ...
Read more >
Versioning an ASP.NET Core API
Microsoft has developed a ready to use NuGet package to support versioning. It supports most of the versioning schema defined in the previous ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found