小编Gam*_*idi的帖子

“ServiceCollection”不包含采用 0 个参数的构造函数

我正在尝试用 C# 创建一个 Discord 机器人,这里的代码会产生一个异常,并显示以下消息:“ServiceCollection”不包含采用 0 个参数的构造函数

_services = new ServiceCollection()
            .AddSingleton(_client)
            .AddSingleton(_commands)
            .BuildServiceProvider();
Run Code Online (Sandbox Code Playgroud)

参考资料(如果有帮助的话)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Services.Description;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
Run Code Online (Sandbox Code Playgroud)

我是编程的初学者,所以任何帮助将不胜感激!

c# dependency-injection

3
推荐指数
1
解决办法
1115
查看次数

标签 统计

c# ×1

dependency-injection ×1