Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

InvalidCastException right after start receiving updates

Open walker93 opened this issue 10 years ago • 1 comments

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?

walker93 avatar Mar 03 '16 21:03 walker93

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

MrRoundRobin avatar Jun 08 '16 18:06 MrRoundRobin