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

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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/


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x