引发异常:Discord.Net.WebSocket.dll中的“ System.IO.FileNotFoundException”

时间:2018-08-11 10:05:27

标签: c# nuget-package discord.net

当我尝试运行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;
}

1 个答案:

答案 0 :(得分:0)

解决了。似乎Visual Studio 15.8.0 Preview 5有一些错误。因此,我学习了有关将预发布软件用于生产软件的课程。

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