Building a proof-of-concept on .NET Core 3.0 preview 7 I ran into issues when developing web APIs. This release is production-ready (according to Microsoft -see below), but every now and then you run into really unintuitive and sometimes surprising issues.
NET Core 3.0 Preview 7 is supported by Microsoft and can be used in production. We strongly recommend that you test your app running on Preview 7 before deploying Preview 7 into production. If you find an issue with .NET Core 3.0, please file a GitHub issue and/or contact Microsoft support.
I was trying to add a reference to Microsoft.AspNetCore.Mvc.Versioning to configure versioning for my APIs. That’s when I ran into issues.
The error pops up when you’re building your solution, and causes the build to fail. The error is shown below:
Method 'ApplyAsync' in type 'Microsoft.AspNetCore.Mvc.Routing.ApiVersionMatcherPolicy' from assembly 'Microsoft.AspNetCore.Mvc.Versioning, Version=184.108.40.206, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
The error message didn’t really give me a clear indication on how to change my code – but luckily the fix was simple. Unfortunate, but simple.
A similar error can likely be caused by other reasons as well, but this particular issue was due to the implementation of Microsoft.AspNetCore.Mvc.Versioning relying on a lot of classes having public accessors. They used to, in 2.0, but in 3.0, they don’t.
This causes the package to be incompatible with .NET Core 3.0.
In fact, the package’s author explained on GitHub, that as of now the package is not supposed to work with .NET Core 3.0 at all. For whatever reasons, NuGet will let you install it, even though it shouldn’t. See the quote below:
ASP.NET Core 3.0 is not supported – yet. The API Versioning package declares Microsoft.AspNetCore.Mvc.Core (>= 2.2.0 && < 3.0.0) so I’m not sure how you able to bypass the NuGet constraints. Regardless, I rarely provide support for prereleases. As a one-man army, I just don’t have the capacity to support a moving target. Furthermore, there hasn’t been any demand to support 3.0. It will be supported when it’s officially released, but until then, all my focus is on existing issues.Commonsensesoftware on GitHub
However, there’s a couple of options you have.
First of all, let’s start with the simple solution: You just remove the offending package(s). In this case, Microsoft.AspNetCore.Mvc.Versioning.
So, head out to your NuGet package manager, find the package, and if it is anything under 4.0.0, hit “Uninstall”.
Now, it’s easy to see that this is not a real solution for a lot of reasons. It might get your builds back to succeeding, so if you don’t really need the versioning right now, you might be good.
However, a lot of you will want to have it. So, consider the below solutions instead:
This package is receiving an update that’ll make it compatible with .NET Core 3.0 once again. The compatible version is Microsoft.AspNetCore.Mvc.Versioning 4.0 preview 8. If you’re reading this soon after original publish, you need to download the package’s code yourself from the link below, as it hasn’t been published on nuget yet:
If you’re reading this a bit later (right now I’m guessing the end of August 2019), the GA version of Microsoft.AspNetCore.Mvc.Versioning 4.0 might be out already – and available on NuGet. In that case, just grab/update the package from there, and you should be good!
For more information, see this thread on GitHub:
He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff.
This is his personal professional (e.g. professional, but definitely personal) blog.
Latest posts by Antti K. Koskela (see all)
- Azure DevOps – how to package a simple DLL? - October 17, 2019
- How to use UriHelper or NavigationManager in .NET Core 3.0 & Blazor? - October 17, 2019
- Azure DevOps build fails with “The nuget command failed with exit code(1) and error(Cannot determine the packages folder to restore NuGet packages.” - October 16, 2019