c# - 你可以使用 microsoft bot framework 4.9 来构建一个带有 core 3.1 的 bot 吗?
问题描述
我用 Bot Framework 模板创建了一个 EchoBot,安装了 bot Framework 4.9,然后将目标 .Net 版本更改为 Core 3.1。现在,我收到以下错误:
System.InvalidOperationException HResult=0x80131509 消息=端点路由不支持“IApplicationBuilder.UseMvc(...)”。要使用 'IApplicationBuilder.UseMvc' 在 'ConfigureServices(...) 中设置 'MvcOptions.EnableEndpointRouting = false'。源=Microsoft.AspNetCore.Mvc.Core
如何修复此错误?
解决方案
https://marketplace.visualstudio.com/items?itemName=BotBuilder.botbuilderv4上的当前 vsix 模板具有 Core 3.1 Echobot 模板。如果您还没有,请更新到新模板。
话虽如此,您不能只更改目标 .Net 版本。2.1 中的一些方法在 3.1 中不再存在(您已经发现)。两个启动文件的快速比较显示:
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();
}
那app.UseMvc();
是您的机器人遇到问题的地方。3.1版本内容如下:
// 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();
}
所以要么更新你的模板,要么更新你的 Startup.cs 文件。
推荐阅读
- reactjs - Cookie 未在跨域 react-flask 应用程序中发送
- javascript - 为什么将js语句传递给按钮中的onclick会立即激活?
- perl - perl msgrcv() errno 22 (EINVAL) Ubuntu
- kotlin - 添加受保护和内部可见性以在 kotlin 中运行
- java - WebFlux 和 Spring-Integration 的奇怪错误 - IndexOutOfBoundsException 超过 maxCapacity
- controls - 将 LSTM+NN 用于 DQN 有意义吗?
- java - 如何将 LocalDate 作为参数传递?
- wso2-am - wso2 api manager 3.2.0 nginx负载均衡这个站点无法访问错误?
- javascript - 在 Firebase 上快速重置用户数据
- wordpress - 根据订单内容更改 woocommerce 客户电子邮件的回复地址