Aspnet-api-versioning: Microsoft.AspNetCore.Mvc.Versioning, Version=3.1.0.0 , ApplyAsync does not have an implementation in .NET Core 3.0 preview6-012264

Created on 13 Jun 2019  路  12Comments  路  Source: microsoft/aspnet-api-versioning

'Method 'ApplyAsync' in type 'Microsoft.AspNetCore.Mvc.Routing.ApiVersionMatcherPolicy' from assembly 'Microsoft.AspNetCore.Mvc.Versioning, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'

asp.net core duplicate

Most helpful comment

@ajaysingh-wg use preview:

<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.0.0-preview8.19405.7" />

All 12 comments

Please see #499. ASP.NET Core 3.0 is not supported - yet

Since this is a duplicate, I'm going to close it out. Please follow #499 for updates.

Hi,
I am facing this issue while migrating my application to .Net Core 3.0. Any work around or solution for this?

@ajaysingh-wg use preview:

<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.0.0-preview8.19405.7" />

I am facing same issue while migrating my dotnetcore 2.2 app to 3.1 from this thread bot clear what solution works.

Below is code which fails at runtime

services.AddApiVersioning(options =>
            {
                options.ReportApiVersions = true;
                options.AssumeDefaultVersionWhenUnspecified = true;
            });

System.TypeLoadException
HResult=0x80131522
Message=Method 'ApplyAsync' in type 'Microsoft.AspNetCore.Mvc.Routing.ApiVersionMatcherPolicy' from assembly 'Microsoft.AspNetCore.Mvc.Versioning, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
Source=Microsoft.AspNetCore.Mvc.Versioning
StackTrace:
at Microsoft.Extensions.DependencyInjection.IServiceCollectionExtensions.AddApiVersioningServices(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.IServiceCollectionExtensions.AddApiVersioning(IServiceCollection services, Action1 setupAction) at NopClient.Services.WebApp.Startup.ConfigureServices(IServiceCollection services) in \Startup.cs:line 72 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection) at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder1.<>c__DisplayClass15_0.g__RunPipeline|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)

@naveenaggarwal1 Do you have some information about your references that you can share? Have you made sure your /obj folder has been cleared and rebuilt? This has all the symptoms of resolving the wrong implementation in the package. I've seen this happen with the wrong target framework (TFM) a number of times.

Thanks @commonsensesoftware . Below is information which will provide more context. Please let me know if this is you were asking

image

References :

using System.Diagnostics.CodeAnalysis;

using AutoMapper;

using Microsoft.ApplicationInsights;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;

And i have cleaned and rebuild the solution and target framework is

image

Yep. Thanks what I'm looking for. Contrary to what people may believe, I'm not part of the ASP.NET team nor have the same release cadence. I tried to keep the version numbers aligned, but they eventually drifted. You are referencing the wrong version of the package. I'm not sure why this wasn't caught during NuGet restore because the upper end is _clipped_:

Microsoft.AspNetCore.Mvc.Core (>= 2.2.0 && < 3.0.0)

You want version 4.1.1+ [[nuget](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Versioning/)]

This package was multi-targeting for a while to support backward compatibility with OData on 2.2 and messed a number of people up. Starting ASP.NET Core 3.0/3.1, you must target netcoreapp3.0/netcoreapp3.1 respectively. It would appear that somehow the .NET Standard 2.0 target was still being referenced, which will compile, but fails _spectacularly_ at runtime with TypeLoadException or MissingMethodException.

Once you update your package version, you should be back in business. I hope that helps.

Thanks @commonsensesoftware for your response. I am not able to get the solution I am seeing currently i am referring the 2.2.0 version package for Microsoft.AspNetCore.Mvc.Core . I can't upgrade the same to 3.1 as it not available in available versions for install as latest available package for same is 2.2.5

image

This will not get you what you want. The can't just update the NuGet packages. The process is different and simplified in ASP.NET Core 3.0+. You no longer reference the litany of NuGet packages. Instead you reference the entire ASP.NET Core platform and the compiler decides what to link to. This is out of my hands and is just how it works. This combination is determined by Sdk="Microsoft.NET.Sdk.Web" + <TargetFramework>netcoreapp3.1</TargetFramework>

You can look at the Basic Example, which shows the most basic ASP.NET Core 3.0+ setup and should help you migrate.

Thanks @commonsensesoftware for help. I am able to build for now after referring to particular package as project reference from local folder. But i think this is not the path i want to got. Thanks for help and looking into issue.

Was this page helpful?
0 / 5 - 0 ratings