I created an EchoBot with the Bot Framework template, installed the bot framework 4.9, and then changed the target .Net version to Core 3.1. Now, I get the following error:
System.InvalidOperationException HResult=0x80131509 Message=Endpoint Routing does not support 'IApplicationBuilder.UseMvc(...)'. To use 'IApplicationBuilder.UseMvc' set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices(...). Source=Microsoft.AspNetCore.Mvc.Core
How do I fix this error?
The current vsix templates at https://marketplace.visualstudio.com/items?itemName=BotBuilder.botbuilderv4 have a Core 3.1 Echobot template. If you haven't already, update to the new template.
That being said, you can't just change the target .Net version. There are methods in the 2.1 that no longer exist in 3.1 (which you've discovered). A quick comparison of the two startup files shows:
2.1:
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseWebSockets();
//app.UseHttpsRedirection();
app.UseMvc();
}
where that app.UseMvc();
is where your bot is having issues. The 3.1 version reads:
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDefaultFiles()
.UseStaticFiles()
.UseWebSockets()
.UseRouting()
.UseAuthorization()
.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
// app.UseHttpsRedirection();
}
So either update your template, or update your Startup.cs file.
User contributions licensed under CC BY-SA 3.0