I’m following a tutorial for making a discord bot, and after following the basics for setting up a bot I keep running into this exception:
System.Reflection.TargetInvocationException has been thrown. Exception has been thrown by the target of an invocation.
This is the code I have:
using Discord.Commands;
using Discord;
using System;
namespace TestBot
{
public class MyBot
{
DiscordClient discord;
public MyBot()
{
discord = new DiscordClient(x =>
{
x.LogLevel = LogSeverity.Info;
x.LogHandler = Log;
});
discord.UsingCommands(x =>
{
x.PrefixChar = '!';
x.AllowMentionPrefix = true;
});
var commands = discord.GetService<CommandService>();
commands.CreateCommand("test")
.Do(async (e) =>
{
await e.Channel.SendMessage("response");
});
discord.ExecuteAndWait(async () =>
{
await discord.Connect("BOT_TOKEN", TokenType.Bot);
});
}
private void Log(object sender, LogMessageEventArgs e)
{
Console.WriteLine(e.Message);
}
}
}
MonoDevelop says that the exception is happening with this piece of code:
discord.ExecuteAndWait(async () =>
{
await discord.Connect("BOT_TOKEN", TokenType.Bot);
});
I don’t know how to fix this, so any help would be greatly appreciated.
(As this is my first post here, any suggestions on how to improve my posts are also appreciated.)
asked Oct 16, 2016 at 4:18
EsrelithEsrelith
991 gold badge1 silver badge7 bronze badges
3
The true cause for your exception is being hidden from you. To fix this issue you will need to view the inner exception (and if required the inner exception of that exception and so on..). This will allow you to see the root cause of the issue and allow you to workout how to fix it.
You can view the inner exception when your code breaks in debug mode;
Clicking view detail will allow you to see more information about your exception;
Once you get to the true cause of your exception I suggest you post a new question asking how to solve that specific issue (if you can’t solve it yourself).
answered Oct 16, 2016 at 7:25
mark_hmark_h
5,1133 gold badges34 silver badges52 bronze badges
1
In my case, it’s caused by some exception in some inner code, and the exception was throwed up through the stack, when come to the surface and show exception window, the exception message has been losed so it shows a useless message System.Reflection.TargetInvocationException has been thrown.
The solution is, open Exception Settings Window, and check all items so that it’ll break when any type of Exception happens, so you can catch the exception at the most initial position that the error reason can be esaily undederstood.
My idea comes from HERE.
answered Nov 17, 2017 at 6:21
yu yang Jianyu yang Jian
6,5327 gold badges54 silver badges79 bronze badges
При запуске лаунчер выдает ошибку
Чтобы отвечать, сперва войдите на форум
Kwizi
Наблюдатель
На форуме с
09 августа 19
System.Reflection.TargetInvocationException:Адресат вызова создал исключение
Прикрепленные миниатюры
aby
Создатель портала
На форуме с
23 мая 06
в директории %localappdata% удалите папку strikearena.ru должно помочь
Ogurchik_
Наблюдатель
На форуме с
21 февраля 20
в директории %localappdata% удалите папку strikearena.ru должно помочь
нашел только*strikearena* удалил, не помогло
Sania(ZoS)
Администратор портала
На форуме с
06 октября 19
нашел только*strikearena* удалил, не помогло
ваш скриншот и текст проблемы в студию
Ogurchik_
Наблюдатель
На форуме с
21 февраля 20
ваш скриншот и текст проблемы в студию
собственно вот:
появляется при запуске *launcher_SA.exe
если это важно конечно, то оффлайн запускается
Изменено: Ogurchik_, 23 февраля 2020 — 05:04
Прикрепленные миниатюры
Ogurchik_
Наблюдатель
На форуме с
21 февраля 20
Sania(ZoS)
Администратор портала
На форуме с
06 октября 19
i need help
попробуй переустановить/обновить net framework до версии 4.8
VovaDok
Наблюдатель
На форуме с
22 февраля 20
попробуй переустановить/обновить net framewor
У меня была похожая проблема ! Лаунчер ,не как не хотел открываться все танцы с бубном я проделал. Но так и не чего не помогло . Тогда я скачал клиент игры 1,7 с другого ресурса. Закинул туда апдейтер , все им проверил , долго и нудно. Закинул лаунчер и …. все заработало вчера погонял на 2 сервере онлайн 55 челов)))
Ogurchik_
Наблюдатель
На форуме с
21 февраля 20
попробуй переустановить/обновить net framework до версии 4.8
не помогло! Есть еще варианты?
У меня была похожая проблема ! Лаунчер ,не как не хотел открываться все танцы с бубном я проделал. Но так и не чего не помогло . Тогда я скачал клиент игры 1,7 с другого ресурса. Закинул туда апдейтер , все им проверил , долго и нудно. Закинул лаунчер и …. все заработало вчера погонял на 2 сервере онлайн 55 челов)))
можно ссылку? в личку или так, хочу попробовать
Sania(ZoS)
Администратор портала
На форуме с
06 октября 19
не помогло! Есть еще варианты?
можно ссылку? в личку или так, хочу попробовать
есть, отписать Абу с личного кабинета или на сайте тут же, либо винду переставить
Ogurchik_
Наблюдатель
На форуме с
21 февраля 20
есть, отписать Абу с личного кабинета или на сайте тут же, либо винду переставить
что такое *абу*?
Sania(ZoS)
Администратор портала
На форуме с
06 октября 19
rogachef
Наблюдатель
На форуме с
13 июля 20
Народ столкнулся с такой же проблемой при запуске лаунчера. Офлайн версия работает.
Подскажите что сделать?
Изменено: rogachef, 14 июля 2020 — 01:02
-=VeteR=-
Администратор портала =========== Гоняет стаи туч
На форуме с
14 июля 19
Народ столкнулся с такой же проблемой при запуске лаунчера. Офлайн версия работает.
Подскажите что сделать?
Скриншот приложите
-=VeteR=-
Администратор портала =========== Гоняет стаи туч
На форуме с
14 июля 19
В папке с игрой находите DayZ Fixer, открываете,, выключаете защитник, брандмауэр и смарт скрин. Если есть дополнительные антивирусы (Аваст) — удаляете или полностью выключаете. После этого в папке с игрой открываете updater, выбираете любой из 4 серверов и нажимаете «Начать». После завершения должно работать.
Изменено: -=VeteR=-, 14 июля 2020 — 01:44
rogachef
Наблюдатель
На форуме с
13 июля 20
Победил, скачав заново только лаунчер, и добавил его в исключение антивируса. Апдейтером 3 раза проверял, не помогло.
Подскажите еще где скачать папку с модами @STALKERDZ? В дискорде ссылки нет для нон-стим.
Изменено: rogachef, 14 июля 2020 — 02:25
-=VeteR=-
Администратор портала =========== Гоняет стаи туч
На форуме с
14 июля 19
Победил, скачав заново только лаунчер, и добавил его в исключение антивируса. Апдейтером 3 раза проверял, не помогло.
Подскажите еще где скачать папку с модами @STALKERDZ? В дискорде ссылки нет для нон-стим.
То что я писал нужно было делать в порядке очереди….
User50092 posted
Hi I got this error when i navigate to a page from a list view in xamarin forms . I can’t find the actual problem can any one help he to find where the problem is happening from this report . am using MVVMLight
[0:] Error NavigateTo BenWorkTasksPage. Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
at Xamarin.Forms.Label.FontStructPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle) [0x00000] in <filename unknown>:0
at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, Boolean fromStyle) [0x000a4] in <filename unknown>:0
at Xamarin.Forms.Style.ApplyCore (Xamarin.Forms.BindableObject bindable, Xamarin.Forms.Style basedOn) [0x0001e] in <filename unknown>:0
at Xamarin.Forms.Style.Xamarin.Forms.IStyle.Apply (Xamarin.Forms.BindableObject bindable) [0x0003e] in <filename unknown>:0
at Xamarin.Forms.VisualElement+MergedStyle.SetStyle (IStyle implicitStyle, IStyle classStyle, IStyle style) [0x00111] in <filename unknown>:0
at Xamarin.Forms.VisualElement+MergedStyle.set_Style (IStyle value) [0x0000d] in <filename unknown>:0
at Xamarin.Forms.VisualElement+<>c.<.cctor>b__211_6 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00000] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0
at IWSM.XamarinApp.Views.BenWorkTasksPage.InitializeComponent () [0x0af0c] in <filename unknown>:0
at IWSM.XamarinApp.Views.BenWorkTasksPage..ctor (IWSM.Shared.DataModels.WorkTaskDataModel wtdm) [0x00008] in D:Shamnad_TFS_WorkspaceIWSM.XamarinAppIWSM.XamarinAppIWSM.XamarinAppViewsBenWorkingBenWorkTasksPage.xaml.cs:31
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00089] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:635
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:663
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at IWSM.XamarinApp.Common.NavigationService+<NavigateTo>d__15.MoveNext () [0x00173] in D:Shamnad_TFS_WorkspaceIWSM.XamarinAppIWSM.XamarinAppIWSM.XamarinAppCommonNavigationService.cs:115
[0:] OnItemTapped: IWSM.Shared.DataModels.WorkTaskDataModel
[0:] Error NavigateTo BenWorkTasksPage. Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
at Xamarin.Forms.Label.FontStructPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle) [0x00000] in <filename unknown>:0
at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, Boolean fromStyle) [0x000a4] in <filename unknown>:0
at Xamarin.Forms.Style.ApplyCore (Xamarin.Forms.BindableObject bindable, Xamarin.Forms.Style basedOn) [0x0001e] in <filename unknown>:0
at Xamarin.Forms.Style.Xamarin.Forms.IStyle.Apply (Xamarin.Forms.BindableObject bindable) [0x0003e] in <filename unknown>:0
at Xamarin.Forms.VisualElement+MergedStyle.SetStyle (IStyle implicitStyle, IStyle classStyle, IStyle style) [0x00111] in <filename unknown>:0
at Xamarin.Forms.VisualElement+MergedStyle.set_Style (IStyle value) [0x0000d] in <filename unknown>:0
at Xamarin.Forms.VisualElement+<>c.<.cctor>b__211_6 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00000] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0
at IWSM.XamarinApp.Views.BenWorkTasksPage.InitializeComponent () [0x0af0c] in <filename unknown>:0
at IWSM.XamarinApp.Views.BenWorkTasksPage..ctor (IWSM.Shared.DataModels.WorkTaskDataModel wtdm) [0x00008] in D:Shamnad_TFS_WorkspaceIWSM.XamarinAppIWSM.XamarinAppIWSM.XamarinAppViewsBenWorkingBenWorkTasksPage.xaml.cs:31
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00089] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:635
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:663
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at IWSM.XamarinApp.Common.NavigationService+<NavigateTo>d__15.MoveNext () [0x00173] in D:Shamnad_TFS_WorkspaceIWSM.XamarinAppIWSM.XamarinAppIWSM.XamarinAppCommonNavigationService.cs:115
Sorry to wake up your question.
I was already using such asyncBindingList in my implementation.
As i start a new implementation, i choose to not use it anymore, i didn’t remember really the reason for what i am using such class.
So i fall again in the described exception….
And i found your question and solution that describe very well the problem.
But i am a little confused…
For my example, the Data object (so the list that could become asyncbindinglist) have several client on the ListChanged event : bunsines object and the ui…
If am using the Solution3, all event handler will be call from the ui thread ! Also event handler of other business object ! This is really strange ! No ?
For me i think that the problem is more in the implementation of each event handler subscribed to the ListChanged event. The UI should protect itself for the thread problem. Usually, when we are making a manual databinding (as your solution 2), we always take into account this thread problem (as your solution 2 does…). So why the DataGridView does not do that in its event handler implementation in its databinding management ??? It is a bug, a limitation ?
Finally, for me, psychologically, the bette solution should on the event handler implementation, so on the ui side. Yes, the workaround of the asyncbindinglist works, but is uses the ui thread to call ALL event handler !
Maybe the fatest solution should be to have an AsyncBindingList on the ui side. The ui should need to synchronise its AsyncBindingList with the «official» list. Then the datagridview can use this protected AsyncBindingList, dedicated only to it.
In fact, the AsyncBindingList replace the DataSource. (I d’ont understand the utility of this last one, as thread issue is not checked by it…)
But whit this solution, you have your list twice in the memory…. And finally, in place of populate our personal AsyncBindingList in the EventHandler of the official List, the ui could directly modify the datgridview ?
Finally, maybe someone, does a implementation of a datagridview with a «thred protected» DataBinding feature ?
If not, maybe i will add a DataSource to our AsyncBindingListclass to can use it only for the ui context (and not for all business object) ?
What do you think ?
Describe the bug
Since updating a project to the latest version of WinUI3 (Reunion 0.5) we receive the following error whenever trying to debug:
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=System.Private.CoreLib
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) in /_/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs:line 4005
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) in /_/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs:line 4062
at System.Activator.CreateInstance[T]() in /_/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs:line 151
at WinRT.WeakLazy`1.get_Value()
at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance()
at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback)
at Project.Program.Main(String[] args) in C:UsersUSERSourceReposProjectProject.UIProject.UIobjx64Debugnet5.0-windows10.0.19041.0App.g.i.cs:line 26
This exception was originally thrown at this call stack:
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(int) in Marshal.cs
WinRT.BaseActivationFactory.BaseActivationFactory(string, string)
Microsoft.UI.Xaml.Application._IApplicationStatics._IApplicationStatics()
Inner Exception 1:
COMException: Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
Steps to reproduce the bug
We used a project created in WinUI3 v3 and followed the official instructions to upgrade to Reunion 0.5. The original project works as expected until Reunion is installed/WinUI3 removed — then we are unable to run the project with the CLASSNOTREG error.
Expected behavior
The project will run as before.
Screenshots
Version Info
NuGet package version:
Microsoft.ProjectReunion-v0.5.0-prerelease
Microsoft.ProjectReunion.Foundation-v0.5.0-prerelease
Microsoft.ProjectReunion.WinUI-v0.5.0-prerelease
Windows app type:
Win32
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
October 2020 Update (19042) | Yes |
May 2020 Update (19041) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Xbox | |
Surface Hub | |
IoT |