using c#, Visual studio 2013, Windows Store App
A little bit long explanation
Create some simple Windows Store App that works with JSON stored data. After increasing of data amount I start to get a message Unhandled win32 exception occured in AppName [procId].
- please see pic below:
I try to reduce amount of stored data in JSON file, but after some time off work during debugging I got this message again. So situation - if I have a lot of data - I can do few operations (few means 5) in app and got this exception, if I have minimum amount of data I can work with app a little bit more (mean 12-17 different operation). Operation means - read from file, save, load pages etc.
I googling a little bit and found few possible causes:
I must to setup DEP at PC, following next steps:
Try - not helps
Try - not helps
Try - not helps
Found next:
An unhandled win32 exception occurred in . Just-In-Time debugging this exception failed with the following error: The logged in user did not have access to debug the crashing application. This message indicates that Just-In-Time debugging failed because you do not have proper access permissions.
So, mean you do not have proper access permissions.
Try to launch with Administrator rights my App:
Try - not helps
Found this and so this MSDN post useful. Try to add some code to my app:
public MainPage()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += navigationHelper_LoadState;
this.navigationHelper.SaveState += navigationHelper_SaveState;
TimeBinding();
Application.Current.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
string e = args.Message.ToString();
}
but nothing catched...
So, try - not helps
Questions:
"Unhandled win32 exception occured in AppName [procId]."
?UnhandledException
? Maybe I'm wrong with it and so I can't catch required exception (I'm just studying for .NET)?A few months ago, I designed a Error Control System for this job actually. In this project I used this main codes to catch any win32 application exceptions:
System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// Catch all handled exceptions in managed code, before the runtime searches the Call Stack
AppDomain.CurrentDomain.FirstChanceException += FirstChanceException;
// Catch all unhandled exceptions in all threads.
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
// Catch all unobserved task exceptions.
TaskScheduler.UnobservedTaskException += UnobservedTaskException;
// Catch all unhandled exceptions.
System.Windows.Forms.Application.ThreadException += ThreadException;
// Catch all WPF unhandled exceptions.
Dispatcher.CurrentDispatcher.UnhandledException += DispatcherUnhandledException;
And listener methods:
/// <summary>
/// Used for handling WPF exceptions bound to the UI thread.
/// Handles the <see cref="System.Windows.Threading.DispatcherUnhandledExceptionEventHandler"/> events.
/// </summary>
[HandleProcessCorruptedStateExceptions]
private static DispatcherUnhandledExceptionEventHandler DispatcherUnhandledException
{
// catch error ...
}
/// <summary>
/// Used for handling WinForms exceptions bound to the UI thread.
/// Handles the <see cref="System.Threading.ThreadExceptionEventHandler"/> events in <see cref="System.Windows.Forms.Application"/> namespace.
/// </summary>
[HandleProcessCorruptedStateExceptions]
private static ThreadExceptionEventHandler ThreadException
{
// catch error ...
}
/// <summary>
/// Used for handling general exceptions bound to the main thread.
/// Handles the <see cref="AppDomain.UnhandledException"/> events in <see cref="System"/> namespace.
/// </summary>
[HandleProcessCorruptedStateExceptions]
private static UnhandledExceptionEventHandler UnhandledException
{
// catch error ...
}
/// <summary>
/// Used for handling System.Threading.Tasks bound to a background worker thread.
/// Handles the <see cref="UnobservedTaskException"/> event in <see cref="System.Threading.Tasks"/> namespace.
/// </summary>
[HandleProcessCorruptedStateExceptions]
private static EventHandler<UnobservedTaskExceptionEventArgs> UnobservedTaskException
{
// catch error ...
}
/// <summary>
/// This is new to .Net 4 and is extremely useful for ensuring that you ALWAYS log SOMETHING.
/// Whenever any kind of exception is fired in your application, a FirstChangeExcetpion is raised,
/// even if the exception was within a Try/Catch block and safely handled.
/// This is GREAT for logging every wart and boil, but can often result in too much spam,
/// if your application has a lot of expected/handled exceptions.
/// </summary>
[HandleProcessCorruptedStateExceptions]
private static EventHandler<FirstChanceExceptionEventArgs> FirstChanceException
{
// catch error ...
}
If throw an exception within your codes, you must be sure to catch that by this events, but when a exception occurred before executing application then this events don't raised to show or do any things.
For example your are not exactly added all references assemblies to your project then this caused to throw an exception in application startup times.
And some another exceptions maybe have innerException because raised from a thread
or task
s. So you must be checked all exception.innerException
.
I'm hope to presented a solution for your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With