✅ async Task throws exception if not explicitly defined

I have been using asynchronous Tasks all over my project to fetch and send data to a database perfectly fine. But for some reason any async Tasks in one database table handler class throws an exception (See Image). I can fix it by explicitly defining Task to be using Task = System.Threading.Tasks.Task; but that doesnt make any sense to me since it uses the exact same using statements as another database handler class which works perfectly fine and Task isnt defined by anything else at all. Just need some help solving this mystery
31 Replies
Tinefol
Tinefol2y ago
Can you show that table's schema?
Gamingtoday093
Gamingtoday093OP2y ago
The exception is thrown when Invoking the async Task
Tinefol
Tinefol2y ago
snippet of code at least, kinda hard to guess looking just at the error message
Gamingtoday093
Gamingtoday093OP2y ago
so await sillyHandler.SillyAsyncTask();
public async Task SillyAsyncTask()
{
// Code in here doesnt even run
}
public async Task SillyAsyncTask()
{
// Code in here doesnt even run
}
Tinefol
Tinefol2y ago
that doesn't help much :/
Gamingtoday093
Gamingtoday093OP2y ago
Gamingtoday093
Gamingtoday093OP2y ago
Gamingtoday093
Gamingtoday093OP2y ago
is that better? Keep in mind that it only happens if I dont use this (Only required in that specific class) using Task = System.Threading.Tasks.Task; Hold on I think I can peek at the IL
Tinefol
Tinefol2y ago
That's also suspiciously low version in the error. I mean 4.0.0.0 ?
Gamingtoday093
Gamingtoday093OP2y ago
I am using .Net Framework 4.6.1 so it could be that
Tinefol
Tinefol2y ago
oh, old .NET framework Are you really sure Task class doesn't have any conflicting declarations? Seems super weird Can you show the usings?
Gamingtoday093
Gamingtoday093OP2y ago
If I remove using System.Threading.Tasks; Task is undefined and it recommends using either
Gamingtoday093
Gamingtoday093OP2y ago
sure
Gamingtoday093
Gamingtoday093OP2y ago
Tinefol
Tinefol2y ago
Is there any difference in how database handlers are invoked? i mean the one that works and one that doesn't
Gamingtoday093
Gamingtoday093OP2y ago
I found something comparing them in dnSpy
Gamingtoday093
Gamingtoday093OP2y ago
Gamingtoday093
Gamingtoday093OP2y ago
when explicitly defined it uses 0 instead of CSharpBinderFlags.None ah and CSharpBinderFlags is defined in Microsoft.CSharp.RuntimeBinder
Tinefol
Tinefol2y ago
Which it doesn't find I guess
Gamingtoday093
Gamingtoday093OP2y ago
Wait all of this is because the Convert caused by Dapper returning a dynamic If I wasnt so Silly and told it the type it wont have to do all the Convert stuff Lemme see if that fixes it
Tinefol
Tinefol2y ago
it should
Gamingtoday093
Gamingtoday093OP2y ago
There is not Oh that was it wow I am silly Totally missed that somehow
Tinefol
Tinefol2y ago
I'm still baffled, I mean, that dll is not included or something?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Gamingtoday093
Gamingtoday093OP2y ago
my own To give some context, I am developing a server plugin for a game made in Unity. The game doesnt have Microsoft.CSharp as part of its assembly. While I could add it as a library to my plugin, which would solve the original issue, Id rather not include an entire basically unused library.
Tinefol
Tinefol2y ago
oh, Unity. And old .net framework. A combo 🙂 While I've worked with old framework, I'm not proficient with Unity at all
Gamingtoday093
Gamingtoday093OP2y ago
But yeah problem solved so yay spineline , gonna close this issue now
Tinefol
Tinefol2y ago
good luck with your development!
Gamingtoday093
Gamingtoday093OP2y ago
Oh and thanks so much for the help, Forgot to say that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Gamingtoday093
Gamingtoday093OP2y ago
Thx
Want results from more Discord servers?
Add your server