From 48b76a84bee18521d591a4a32289c155a1cb8a46 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Tue, 15 Sep 2020 16:42:40 +0200 Subject: [PATCH] Update SessionBase.cs - improving handling for Sessions loading with no default constructors available. --- TelegramBotBase/SessionBase.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/TelegramBotBase/SessionBase.cs b/TelegramBotBase/SessionBase.cs index ad3f407..e0648c9 100644 --- a/TelegramBotBase/SessionBase.cs +++ b/TelegramBotBase/SessionBase.cs @@ -130,7 +130,19 @@ namespace TelegramBotBase continue; } - var form = t.GetConstructor(new Type[] { }).Invoke(new object[] { }) as FormBase; + var form = t.GetConstructor(new Type[] { })?.Invoke(new object[] { }) as FormBase; + + //No default constructor + if (form == null) + { + form = Activator.CreateInstance(t) as FormBase; + + if (form == null) + { + continue; + } + } + if (s.Values != null && s.Values.Count > 0) {