C
C#ā€¢2y ago
Seventy

ā” System.typeloadexception could not find method due to type load error

Code I am using:
async void GamerMethod()
{
//Doing gamer things...


await GamerSpace.Grabber.Should_Send_Hello_World_Message();
}




public static async Task Should_Send_Hello_World_Message()
{
var message = new DiscordMessage("Hello World!");
var client = new DiscordWebhookClient("//my super cool url");
await client.SendToDiscord(message);
Assert.IsTrue(true);
}
async void GamerMethod()
{
//Doing gamer things...


await GamerSpace.Grabber.Should_Send_Hello_World_Message();
}




public static async Task Should_Send_Hello_World_Message()
{
var message = new DiscordMessage("Hello World!");
var client = new DiscordWebhookClient("//my super cool url");
await client.SendToDiscord(message);
Assert.IsTrue(true);
}
Any ideas why i am getting that error? (feel like i am doing something wrong and its really dumb šŸ’€ )
18 Replies
Angius
Angiusā€¢2y ago
Well, async void is a red flag for sure
Seventy
SeventyOPā€¢2y ago
<:emoji_178:1043823202809417880> šŸ™ please, explain.
Angius
Angiusā€¢2y ago
void cannot be awaited, cannot be cancelled, nothing can be done with it because it is nothing If a method is async then it has to return a Task The only exception being methods you bind to events in some UI frameworks like Winforms and WPF
Seventy
SeventyOPā€¢2y ago
so what do i do, if i remove async i get and error.
Angius
Angiusā€¢2y ago
Make it async Task
Seventy
SeventyOPā€¢2y ago
Angius
Angiusā€¢2y ago
uh I've never seen this interface lol
Seventy
SeventyOPā€¢2y ago
Unity Explorer
Angius
Angiusā€¢2y ago
Ah, some Unity stuff I'd ask in the $unity server tbh
Angius
Angiusā€¢2y ago
Seems like it might be some Unity-specific issue
Seventy
SeventyOPā€¢2y ago
ĀÆ\_(惄)_/ĀÆ
Angius
Angiusā€¢2y ago
Maybe the Discord library you're using isn't compatible with Unity's outdated version of Mono or something
Seventy
SeventyOPā€¢2y ago
do you know one that works with .net 2.0?
Angius
Angiusā€¢2y ago
Afraid not
Seventy
SeventyOPā€¢2y ago
waaaaaaaaaahhhhhh for your help tho!
Anton
Antonā€¢2y ago
if a method is called by unity, it should be async void, otherwise your exceptions are ignored and you won't see them if it's something you call from another method, always make it a task. here, it's the other way. if you don't make it a task and await it, you won't see the exceptions
Accord
Accordā€¢2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server