Skip to content

Conversation

@marvinlehmann
Copy link
Contributor

Added exception handling for closing processes
So there won't be exceptions e.g. when Windows is shutting down (the shutdown process can get interrupted by the error message box).

e.g.:

Exception Found:
Type: System.InvalidOperationException
Message: Die angeforderten Informationen sind nicht verfügbar, da der Prozess beendet wurde.
Source: System
Stacktrace:    bei System.Diagnostics.Process.EnsureState(State state)
   bei System.Diagnostics.Process.get_MainWindowHandle()
   bei System.Diagnostics.Process.get_MainWindowTitle()
   bei vibrance.GUI.common.WinEventHook.WinEventProc(IntPtr hWinEventHook, UInt32 eventType, IntPtr hwnd, Int32 idObject, Int32 idChild, UInt32 dwEventThread, UInt32 dwmsEventTime) in E:\Development\Repositories\vibranceGUI\vibrance.GUI\common\WinEventHook.cs:Zeile 242.
Exception String: System.InvalidOperationException: Die angeforderten Informationen sind nicht verfügbar, da der Prozess beendet wurde.
   bei System.Diagnostics.Process.EnsureState(State state)
   bei System.Diagnostics.Process.get_MainWindowHandle()
   bei System.Diagnostics.Process.get_MainWindowTitle()
   bei vibrance.GUI.common.WinEventHook.WinEventProc(IntPtr hWinEventHook, UInt32 eventType, IntPtr hwnd, Int32 idObject, Int32 idChild, UInt32 dwEventThread, UInt32 dwmsEventTime) in E:\Development\Repositories\vibranceGUI\vibrance.GUI\common\WinEventHook.cs:Zeile 242.

Changed ProcessExplorer reload button to not clear list when busy
So you won't get a splitted list when hitting the button too fast.

So you won't get a splitted list when hitting the button too fast.
So there won't be exceptions e.g. when Windows is shutting down (the shutdown process can get interrupted by the error message box).
@juv
Copy link
Owner

juv commented Jun 7, 2017

Thanks for contributing.
Code looks fine, but I'm not sure about the calls to VibranceGUI.Log().
How often do these Exceptions get thrown? Is it generating a lot of data on the users' computer over time?
Also, I guess it might not the best idea to start writing to files when the filesystem is trying to shut down?

@marvinlehmann
Copy link
Contributor Author

marvinlehmann commented Jun 7, 2017

InvalidOperationException was thrown ~every second shutdown.
ArgumentException was never thrown for me but I just wanted to make sure that all exceptions with similiar causes are catched. Should I just suppress the exceptions? Probably better, I guess because these aren't common errors in general. I wasn't quite sure. :)

EDIT: I also want to note that the process explorer logs a caught exception everytime when reloading.

Exception Found:
Type: System.IO.FileNotFoundException
Message: C:\Windows\system32\ApplicationFrameHost.exe
Source: System.Drawing
Stacktrace:    bei System.Drawing.Icon.ExtractAssociatedIcon(String filePath, Int32 index)
   bei System.Drawing.Icon.ExtractAssociatedIcon(String filePath)
   bei vibrance.GUI.common.ProcessExplorer.GetAllProcesses() in E:\Development\Repositories\vibranceGUI\vibrance.GUI\common\ProcessExplorer.cs:Zeile 52.
Exception String: System.IO.FileNotFoundException: C:\Windows\system32\ApplicationFrameHost.exe
   bei System.Drawing.Icon.ExtractAssociatedIcon(String filePath, Int32 index)
   bei System.Drawing.Icon.ExtractAssociatedIcon(String filePath)
   bei vibrance.GUI.common.ProcessExplorer.GetAllProcesses() in E:\Development\Repositories\vibranceGUI\vibrance.GUI\common\ProcessExplorer.cs:Zeile 52.

https://github.com/juvlarN/vibranceGUI/blob/master/vibrance.GUI/common/ProcessExplorer.cs#L52

I don't exactly know why it can't extract the icon of it..
We could suppress the FileNotFoundException though.

EDIT2:
I forgot about WOW64 where a redirection to %WinDir%\SysWOW64 is enabled by default..
So a simple File.Exists(path) will do it.

Added a File.Exists(path) check because Icon.ExtractAssociatedIcon can throw a FileNotFoundException when the path is e.g. "C:\Windows\system32\ApplicationFrameHost.exe".
VibranceGUI is x86 so it runs under WOW64 on x64 systems and when it tries to access the system32 folder, the access will be redirected to %WinDir%\SysWOW64 but there isn't any ApplicationFrameHost.exe.

Removed exception logging for closing processes because it's simply unnecessary and slowly creates useless data over time.
It's very unlikely that they will happen when not shutting down the PC.
@juv juv merged commit 160f7f8 into juv:master Jun 8, 2017
@juv
Copy link
Owner

juv commented Jun 8, 2017

Thanks :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants