抛出异常:'System.IO.FileNotFoundException' in Discord.Net.WebSocket.dll

Exception thrown: 'System.IO.FileNotFoundException' in Discord.Net.WebSocket.dll

当我尝试 运行 我的 Discord.NET C# 机器人时,抛出 FileNotFoundException。 它还说:

Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=xxxx' or one of its dependencies. The system cannot find the file specified.

我的代码基于文档中的示例构建:

public static void Main(string[] args)
    => new Program().MainAsync().GetAwaiter().GetResult();

public async Task MainAsync()
{
    DiscordSocketClient discordSocketClient = new DiscordSocketClient();

    discordSocketClient.Log += Log;
    discordSocketClient.MessageReceived += DiscordSocketClient_MessageReceived;

    await discordSocketClient.LoginAsync(TokenType.Bot, "xxxx");
    await discordSocketClient.StartAsync();

    await Task.Delay(-1);
}

private async Task DiscordSocketClient_MessageReceived(SocketMessage arg)
{
    // Do stuff...
}

private Task Log(LogMessage logMessage)
{
    Console.WriteLine(logMessage.ToString());
    return Task.CompletedTask;
}

已修复。 Visual Studio 15.8.0 Preview 5 似乎有一些错误。所以我已经吸取了关于将预发布软件用于生产软件的教训。

我安装了稳定版并重新创建了项目,它已修复:)