如何将 BotFramework 的 EchoBot 连接到数据库?
How to connect BotFramework's EchoBot to a database?
因此,我使用 C# 中的 Azure BotFramework 创建了一个机器人并下载了源代码。代码在 .NET Core V 2.1
现在我想通过将聊天机器人连接到数据库来自定义聊天机器人,为此我在添加 class、startup.cs 文件后添加了一个 class DAL.cs在 ConfigureServices
中抛出错误
'EchoBot' is a namespace but used like a type
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// Create the Bot Framework Adapter.
services.AddSingleton<IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();
// Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
services.AddTransient<IBot, EchoBot>();
}
如何将它连接到数据库?
您似乎有一个名为 EchoBot 的命名空间,请将您的命名空间更新为另一个以解决错误
命名空间和 class 名称相同时会发生这种情况。您声明的名称空间 namespace EchoBot
与 class 名称冲突。您必须将命名空间重命名为不同的名称。请参阅 this 博客以帮助更好地理解它。
希望对您有所帮助。
因此,我使用 C# 中的 Azure BotFramework 创建了一个机器人并下载了源代码。代码在 .NET Core V 2.1
现在我想通过将聊天机器人连接到数据库来自定义聊天机器人,为此我在添加 class、startup.cs 文件后添加了一个 class DAL.cs在 ConfigureServices
中抛出错误'EchoBot' is a namespace but used like a type
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// Create the Bot Framework Adapter.
services.AddSingleton<IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();
// Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
services.AddTransient<IBot, EchoBot>();
}
如何将它连接到数据库?
您似乎有一个名为 EchoBot 的命名空间,请将您的命名空间更新为另一个以解决错误
命名空间和 class 名称相同时会发生这种情况。您声明的名称空间 namespace EchoBot
与 class 名称冲突。您必须将命名空间重命名为不同的名称。请参阅 this 博客以帮助更好地理解它。
希望对您有所帮助。