简体   繁体   English

无法在WPF中调用SendCodeRequestAsync方法

[英]Cant able to call SendCodeRequestAsync method in WPF

I am stuck at one point while using TLSharp library for using Telegram API in .Net. 在使用TLSharp库在.Net中使用Telegram API时,我陷入了困境。 Below is my code that i am trying to send a code request using client.SendCodeRequestAsync() method 以下是我尝试使用client.SendCodeRequestAsync() method发送代码请求的代码

            client = new TelegramClient(238363, "9f176b5a6eec1efc8ff58bbc7766e266");
            await client.ConnectAsync();
            var hash = await client.SendCodeRequestAsync("91XXXXXXXXXX");
            if (hash != null)
            {
                MessageBox.Show(hash);
            }`

the above code is giving me An address incompatible with the requested protocol was used [2001:b28:f23f:f005::a]:443 error. 上面的代码给了我一个与所请求的协议不兼容的地址,它被使用[2001:b28:f23f:f005 :: a]:443错误。 Don't know what is wrong. 不知道怎么了。 I googled out a lot and tried alot but still the problem remains the same.So please anyone who can help me out. 我在Google上搜索了很多,并尝试了很多,但是问题仍然存在。所以请任何可以帮助我的人。

I finally resolved this problem. 我终于解决了这个问题。 The main reason behind this problem was the IP address version were not matching. 此问题背后的主要原因是IP地址版本不匹配。 So, as per This Refrence I found var dc = dcOptions.First(d => d.Id == dcId); 因此,根据此参考,我发现var dc = dcOptions.First(d => d.Id == dcId); and replaced it with var dc = dcOptions.First(d => d.Id == dcId && !d.Ipv6); 并将其替换为var dc = dcOptions.First(d => d.Id == dcId && !d.Ipv6); this line in TelegramClient.cs file and it worked like charm.. TelegramClient.cs文件中的这一行,它的工作方式就像魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM