title: How to fix "System.Reflection.TargetInvocationException has been thrown"
body: <p>I'm following a tutorial for making a discord bot, and after following the basics for setting up a bot I keep running into this exception: </p>
  
  <p><em>System.Reflection.TargetInvocationException has been thrown. Exception has been thrown by the target of an invocation.</em></p>
  
  <p>This is the code I have:</p>
  
  <pre><code>using Discord.Commands;
  using Discord;
  using System;
  namespace TestBot
  {
      public class MyBot
      {
          DiscordClient discord;
  
          public MyBot()
          {
              discord = new DiscordClient(x =&gt;
              {
                  x.LogLevel = LogSeverity.Info;
                  x.LogHandler = Log;
              });
              discord.UsingCommands(x =&gt;
              {
                  x.PrefixChar = '!';
                  x.AllowMentionPrefix = true;
              });
              var commands = discord.GetService&lt;CommandService&gt;();
  
              commands.CreateCommand("test")
                      .Do(async (e) =&gt;
              {
                  await e.Channel.SendMessage("response");
              });
               discord.ExecuteAndWait(async () =&gt;
              {
                  await discord.Connect("BOT_TOKEN", TokenType.Bot);
              });
  
          }
  
          private void Log(object sender, LogMessageEventArgs e)
          {
              Console.WriteLine(e.Message);
          }
      }
  }
  </code></pre>
  
  <p>MonoDevelop says that the exception is happening with this piece of code:</p>
  
  <pre><code>discord.ExecuteAndWait(async () =&gt;
              {
                  await discord.Connect("BOT_TOKEN", TokenType.Bot);
              });
  </code></pre>
  
  <p>I don't know how to fix this, so any help would be greatly appreciated.</p>
  
  <p>(As this is my first post here, any suggestions on how to improve my posts are also appreciated.)</p>