Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when restart TaskbarX #239

Closed
deluxghost opened this issue Apr 22, 2020 · 5 comments
Closed

Crash when restart TaskbarX #239

deluxghost opened this issue Apr 22, 2020 · 5 comments

Comments

@deluxghost
Copy link

I have this issue even before its name was changed to TaskbarX. The startup task works, but if (for some reason) TaskbarX exits, I can't launch it anymore before rebooting OS, the process just disappears simply after launching.

I can open the configurator, but if I click stop or apply button, the configurator also crashes, and if TaskbarX is still alive, it will crashes/disappears too.

BTW, my Windows version is 1909.

Since I have this issue on old releases too, so I installed 1.5.2.0, and got this crash info when clicking stop button in the configurator:

System.Windows.Automation.ElementNotAvailableException: Element not available ---> System.Runtime.InteropServices.COMException: An event was unable to invoke any of the subscribers (Exception from HRESULT:0x80040201)
   at UIAutomationClient.CUIAutomation8Class.ElementFromHandleBuildCache(IntPtr hwnd, IUIAutomationCacheRequest cacheRequest)
   at System.Windows.Automation.AutomationElement.FromHandle(IntPtr hwnd)
   --- End of inner exception stack trace ---
   at System.Windows.Automation.AutomationElement.FromHandle(IntPtr hwnd)
   at TaskbarX_Configurator.Form1.ResetTaskbarStyle()
   at TaskbarX_Configurator.Form1.Button2_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I'm not sure if it's related since there are no logs in the newest version.

@ChrisAnd1998
Copy link
Owner

@deluxghost I read your issue. Trying to understand why and where it happens.

@deluxghost
Copy link
Author

deluxghost commented Apr 24, 2020

Could you implement any log feature so I can collect and provide more info? I guess it might be a very rare case.

@ChrisAnd1998
Copy link
Owner

@deluxghost Sorry for the late response Currently there's nothing to log TaskbarX. Does it still happen with 1.5.5.0
as it now uses a different approach.

@deluxghost
Copy link
Author

Well, since I am the only one who has this environment to replicate this bug, I decided to debug myself. I don't know VB.NET, but I found a crash case anyway, here it is.

Dim i As Integer = 0
Do While (i < CType(count, Integer))
Dim item As Object = windowsType.InvokeMember("Item", BindingFlags.InvokeMethod, Nothing, windows, New Object() {i})
Dim itemType As Type = item.GetType
Dim itemName As String = CType(itemType.InvokeMember("Name", BindingFlags.GetProperty, Nothing, item, Nothing), String)
If (itemName = "Shell_TrayWnd") Then
itemType.InvokeMember("Refresh", BindingFlags.InvokeMethod, Nothing, item, Nothing)
End If
i = (i + 1)
Loop

The problem is, not all objects have the Name property, I am using a custom file explorer, so I definitely have such a window. If this happens, this line will throw an exception:

Dim itemName As String = CType(itemType.InvokeMember("Name", BindingFlags.GetProperty, Nothing, item, Nothing), String)

My fix:

        Do While (i < CType(count, Integer))
            Dim item As Object = windowsType.InvokeMember("Item", BindingFlags.InvokeMethod, Nothing, windows, New Object() {i})
            Dim itemType As Type = item.GetType
            Dim itemNameInfo As PropertyInfo = itemType.GetProperty("Name")
            If (itemNameInfo <> Nothing) Then
                Dim itemName As String = CType(itemType.InvokeMember("Name", BindingFlags.GetProperty, Nothing, item, Nothing), String)
                If (itemName = "Shell_TrayWnd") Then
                    itemType.InvokeMember("Refresh", BindingFlags.InvokeMethod, Nothing, item, Nothing)
                End If
            End If
            i = (i + 1)
        Loop

@ChrisAnd1998
Copy link
Owner

ChrisAnd1998 commented May 3, 2020

Ohh well, Very nice you started debugging it yourself! The modification still works fine on my end so i will implement it for the next update ;)

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

No branches or pull requests

2 participants