This project has moved. For the latest updates, please go here.
1

Closed

meaningful error message if the environment variable in initializeData is not recognized

description

Environment variable ProgramData is not recognized in XP, and the program will crash at startup creating 2 events.

Source: .NET Runtime 4.0 Error,
Event ID: 5000
Description: EventType clr20r3, P1 myprogram.exe, P2 1.0.0.0, P3 55d13f21, P4 essential.diagnostics, P5 1.2.0.0, P6 540e9190, P7 b7, P8 55, P9 ioibmurhynrxkw0zxkyrvfn0boyyufow, P10 NIL.

Source: .NET Runtime
Event ID: 1026
Description: Application: myprogram.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceInternal.get_Listeners()
at System.Diagnostics.TraceInternal.TraceEvent(System.Diagnostics.TraceEventType, Int32, System.String, System.Object[])
at IdealPos.LicensingClientWin.App.App_DispatcherUnhandledException(System.Object, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs)
at System.Windows.Threading.Dispatcher.CatchException(System.Exception)
at System.Windows.Threading.Dispatcher.CatchExceptionStatic(System.Object, System.Exception)
at System.Windows.Threading.ExceptionWrapper.CatchException(System.Object, System.Exception, System.Delegate)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
at myprogram.App.Main()


It is better to catch the error and give more meaningful message then throw to Windows event.
Closed Sep 3, 2015 at 7:03 AM by zijianhuang
The trace listener is actually throwing Argument exception when the environment variable is not recognized.

In XP, the exception is lost, and somehow the behavior is to create 2 Windows events without useful info revealed.

In Windows 7, the runtime actually catch the exception and show useful exception message in a popup window. And this is desired.

I decide to leave it as it is.

comments

sgryphon wrote Mar 13, 2016 at 10:51 PM

Not sure what this is (I don't think environment variables are supported), so agree with close.