Constructor not found exception

443 Views Asked by At

I can’t understand how to fix that. Basically I can’t get instance of that class only on few clients. I was able to get an instance by using Reflection and dynamically invoke constructor. Has anyone encountered that problem before?

        private static void Instance()
        {
            try
            {
                var bot = new TelegramBotClient("YourToken", (HttpClient) null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
            TextWriterTraceListener myWriter = new
                TextWriterTraceListener(System.Console.Out);
            Debug.Listeners.Add(myWriter);

            var type = typeof(TelegramBotClient);
            foreach (var constructor in type.GetConstructors())
                Console.WriteLine(string.Join(",", constructor.GetParameters().Select(e => e.Name)));
            Instance();
            
        }

Exception

Output:
token,httpClient
token,webProxy

Unhandled Exception: System.MissingMethodException: Method not found: 'Void Tele
gram.Bot.TelegramBotClient..ctor(System.String, System.Net.Http.HttpClient)'.
   at CC_Watcher.Program.Instance()
   at CC_Watcher.Program.Main(String[] args)
0

There are 0 best solutions below