wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
956 stars 156 forks source link

Unable to cast object of type 'TL.UserEmpty' to type 'TL.User'. #242

Closed dmitry-demchuk closed 5 months ago

dmitry-demchuk commented 5 months ago

Hi there, thanks again for the awesome product!

I've just hit an issue using Messages_GetHistory - for some message it throws following exception:

System.InvalidCastException: Unable to cast object of type 'TL.UserEmpty' to type 'TL.User'. at TL.Serialization.ReadTLDictionary[T](BinaryReader reader) at TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb) at TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb) at WTelegram.Client.ReadRpcResult(BinaryReader reader) --- End of stack trace from previous location --- at WTelegram.Client.Invoke[T](IMethod`1 query)

Such message can be found in @ROOTCHAT_OFFICIAL, somewhere between message ids 295687 and 295787. This exception happens in last few versions, including the latest one. I'd appreciate any suggestions.

wiz0u commented 5 months ago

Thanks for the great bug report! This bug existed for quite some time apparently (but UserEmpty is quite the rare thing)

wiz0u commented 5 months ago

Please note that rare UserEmpty will result in the users dictionary possibly containing a null value for that user id. (that's always been the design behind those Dictionary<int, User>)

dmitry-demchuk commented 5 months ago

Wow, that was super fast! Thanks a lot!