✅ 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 mystery31 Replies
Can you show that table's schema?
The exception is thrown when Invoking the async Task
snippet of code at least, kinda hard to guess looking just at the error message
so
await sillyHandler.SillyAsyncTask();
that doesn't help much :/
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 ILThat's also suspiciously low version in the error. I mean 4.0.0.0 ?
I am using .Net Framework 4.6.1 so it could be that
oh, old .NET framework
Are you really sure Task class doesn't have any conflicting declarations? Seems super weird
Can you show the usings?
If I remove
using System.Threading.Tasks;
Task is undefined and it recommends using eithersure
Is there any difference in how database handlers are invoked?
i mean the one that works and one that doesn't
I found something comparing them in dnSpy
when explicitly defined it uses 0 instead of CSharpBinderFlags.None
ah and CSharpBinderFlags is defined in
Microsoft.CSharp.RuntimeBinder
Which it doesn't find I guess
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
it should
There is not
Oh that was it
wow I am silly
Totally missed that somehow
I'm still baffled, I mean, that dll is not included or something?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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.
oh, Unity. And old .net framework. A combo 🙂 While I've worked with old framework, I'm not proficient with Unity at all
But yeah problem solved so yay , gonna close this issue now
good luck with your development!
Oh and thanks so much for the help, Forgot to say that
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thx