Could not load type Microsoft.AspNetCore.Internal.EndpointRoutingApplicationBuilderExtensions from assembly Microsoft.AspNetCore.Routing Ver=3.1.7.0

Viewed 645

I am upgrading my dotnet core 2.2 app to 3.1. I have multiple services and one base library all initially developed in 2.2 AspDotNetCore. My plan is:

  1. First covert my base library to Dotnet standard 2.1. Which I am able to do successfully with few reference changes.
  2. Now I am referencing this base 2.1 dotnet standard library in other AspDotnet core app which I am upgrading from 2.2 dotnet core to 3.1 dotnet core. Here I am getting error as follows.

Could not load type 'Microsoft.AspNetCore.Internal.EndpointRoutingApplicationBuilderExtensions' from assembly 'Microsoft.AspNetCore.Routing, Version=3.1.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

The at which this error occurs is at UseMvcCoreServices which is my custom extension mention:

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHttpContextAccessor ca, IHostApplicationLifetime applicationLifetime)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app
            .UseMvcCoreServices(Configuration, Logger, env)
            .UseElasticClient(Configuration, Logger);

I followed lots of link as: [https://medium.com/@alexandre.malavasi/migration-from-asp-net-core-2-2-to-3-1-real-project-ca382ea7eef7] and [https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio]

But yet no luck. Can someone help me. It's really critical for me.

1 Answers

By default the ASP.NET 3.0 and later versions have Endpoint routing enabled. You only have to add app.UseRouting()’ in the Configure() method of the Startup.cs file, before any other middleware that needs to access routing.

For details please visit this link: https://www.yogihosting.com/aspnet-core-endpoint-routing/

Related