Closed qhfreddy closed 1 year ago
The issue is possibly caused by incomplete auto upgrade due to app crash in the Exit() call, I have removed the culprit hack code (hide icon before Exit()) just now.
To workaround the issue, please restart PersistentWindows, or manually upgrade to 5.38 (not click the upgrade menu) to guarantee a clean restart.
The upgrade I did previously was a manual upgrade, even when removing all related files and clearing the appdata folder the crash still happens. It can still be caused directly with the "Capture a Snapshot" function with the following exception.
System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category)
at Ninjacrab.PersistentWindows.Common.Diagnostics.Log.Event(String format, Object[] args) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.Common\Diagnostics\Log.cs:line 87
at Ninjacrab.PersistentWindows.Common.PersistentWindowProcessor.TakeSnapshot(Int32 snapshotId) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.Common\PersistentWindowProcessor.cs:line 1432
at Ninjacrab.PersistentWindows.SystrayShell.Program.CaptureSnapshot(Int32 id, Boolean prompt) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.SystrayShell\Program.cs:line 335
at Ninjacrab.PersistentWindows.SystrayShell.SystrayForm.CaptureSnapshotClickHandler(Object sender, EventArgs e) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.SystrayShell\SystrayForm.cs:line 282
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I have made a speculative fix, can you please try 5.39
The behaviour appears unchanged. The application still fails to restore windows (from disk or automatically), crashing when it attempts to do so, and when using "Capture a Snapshot" the following Exception is generated.
System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category)
at Ninjacrab.PersistentWindows.Common.Diagnostics.Log.Event(String format, Object[] args) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.Common\Diagnostics\Log.cs:line 92
at Ninjacrab.PersistentWindows.Common.PersistentWindowProcessor.TakeSnapshot(Int32 snapshotId) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.Common\PersistentWindowProcessor.cs:line 1463
at Ninjacrab.PersistentWindows.SystrayShell.Program.CaptureSnapshot(Int32 id, Boolean prompt) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.SystrayShell\Program.cs:line 336
at Ninjacrab.PersistentWindows.SystrayShell.SystrayForm.CaptureSnapshotClickHandler(Object sender, EventArgs e) in H:\proj\PersistentWindows.orig\sourceCode\persistentwindows\Ninjacrab.PersistentWindows.Solution\Ninjacrab.PersistentWindows.SystrayShell\SystrayForm.cs:line 289
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
It seems PersistentWindows does not get the permission to write to event log, and I have no clue how to reproduce it. Can you run PW with admin privilege? If PW would still fail, the workaround is to specify '-silent' as command line option to totally disable event logging.
With admin privilege it still gives the error. It does seem to work fine using the -silent option.
I am running W10 21H1 and recently with 5.34 and also after updating to 5.38 I am getting a "The handle is invalid" exception shortly after starting PW. It also appears to happen when capturing a snapshot.
The application worked fine for a long time and I am not sure what change prompted this error to pop up.
Exception text: