InvalidCastException right after start receiving updates
Hi guys, I'm getting this exception after I start the bot:
System.InvalidCastException was unhandled Message: An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll Additional information: Impossibile eseguire il cast di oggetti di tipo 'Telegram.Bot.Api' sul tipo Telegram.Bot.Types.MessageEventArgs'.
I'm starting the bot like this:
Dim WithEvents api As Api
Sub Main(args() As String)
api = New Api("my-token-here")
load_commands()
api.PollingTimeout = New TimeSpan(0, 0, 20)
api.StartReceiving()
Console.WriteLine("Bot attivato.")
Console.ReadKey()
api.StopReceiving()
End Sub
I'm coding in vb.net instead of c# but this shouldn't be the issue, I tried to use a try-catch block but the exception is not catched there. I can't see the line of code that generates the error, but it occurs right after the StartReceiving() function is called.
I set up the Event Handlers like this:
Public Async Sub processInlineQuery(queryEvent As InlineQueryEventArgs, sender As Object) Handles api.InlineQueryReceived
what can I do to fix this issue? I'm doing something wrong?
Public Async Sub processInlineQuery(queryEvent As InlineQueryEventArgs, sender As Object) Handles api.InlineQueryReceived
has wrong parameter oder, shuld be
Public Async Sub processInlineQuery(sender As Object, queryEvent As InlineQueryEventArgs) Handles api.InlineQueryReceived