question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'The type initializer for 'HandyControl.Controls.Window' threw an exception.'

See original GitHub issue

The exception occurs at Messagebox.Show/Ask/Error etc calls. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

To Reproduce Steps to reproduce the behavior: This happens randomly and I couldn’t find the exact way to reproduce.

Environment (please complete the following information):

  • .net: [.net core 3.1
  • IDE [e.g. vs2019]
  • Version [2.5.3.2]
Stack Trace-
at HandyControl.Controls.Window..ctor()
   at HandyControl.Controls.MessageBox..ctor()
   at HandyControl.Controls.MessageBox.CreateMessageBox(Window owner, String messageBoxText, String caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, String cancelContent, String confirmContent, String yesContent, String noContent)
   at HandyControl.Controls.MessageBox.<>c__DisplayClass44_0.<Ask>b__0()
   at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.Invoke(Action callback)
   at HandyControl.Controls.MessageBox.Ask(String messageBoxText, String caption)
   at demo.ViewModels.MainWindowViewModel.DeleteIconsMethod() in C:\Users\myusername\source\repos\demo\demo\ViewModels\MainWindowViewModel.cs:line 441
   at Prism.Commands.DelegateCommand.Execute()
   at Prism.Commands.DelegateCommand.Execute(Object parameter)
   at Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

image

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DineshSolankicommented, Aug 4, 2020

@NaBian @ghost1372 sorry, I forgot to follow up, I noticed that after removing Notification.Show() from my code, the exception disappeared somehow.I think that should be the culprit. As my app was not in version control at that time, I don’t have the old code. Just before the messageBox, I used to show the notification.see if it helps, else I’ll also try to reproduce again.

0reactions
ghost1372commented, Nov 10, 2021

Hi @NaBian i have a repro, that crash with this bug here you can test it.

HandyControl-s-Project.zip

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Solved] The type initializer for '' threw an exception
TypeInitializationException ". This error is raised due to Static constructor . Actually in my case i am accessing some value from the App.config ......
Read more >
C# Error "The type initializer for ... threw an exception
A Type Initializer exception indicates that the type couldn't be created. This would occur typically right before your call to your method ...
Read more >
Issues · HandyOrg/HandyControl · GitHub
'The type initializer for 'HandyControl.Controls.Window' threw an exception.' bug Something isn't working pending discussion It may take time to discuss.
Read more >
SOLVED the type initializer for module threw an exception ...
this error the type initializer for module threw an exception happened, when you installed upper version of .net framework. to solve this ...
Read more >
System.TypeInitializationException: 'The type initializer for ' ...
System.TypeInitializationException: 'The type initializer for 'Microsoft.Maui.Controls.Shapes.Shape' threw an exception.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found