sharpshell: Explorer crash... again.
Hi.
I’m sorry to bring bad news but the Explorer crash problem is not solved, I have found a bug that causes Explorer to crash in specific circumstances. I’m not sure whether it is the same bug or different.
Here below I’ll explain how to reproduce it, or at least how I think you will be able to reproduce it, this is how my user-interface (my property page) is composed, I don’t have any code running in background and the explorer just crash after some time after the property page is initialized…
- Add a TableLayoutPanel with 0 columns and 2 rows.
- Add a TabControl on the top row.
- Add a Panel on the bottom row.
- Add a Button inside the Panel.
- Add 3 additional tab pages to the TabControl , for a total of 4 tab pages.
- Add a ListView in each tab page.
- Set the “Dock” property value to “Fill” for: TableLayoutPanel, TabControl, Panel and all the ListViews. Or in other words, for all the controls except the Button.
Result would be something like this:

- Compile, register the shell-extension and open/initialize the property page.
- Wait like 1 minute or so until the Explorer crash occur. I have the feeling that the crash will occur faster if the property page lose input focus, or if you hide the window by putting another window to foreground, and then you return the input focus to the property page it will hang and finally Explorer will crash.
Originally I just had put one Listview control in the UI (nothing more) and all worked perfect after #222 fix, but now after doing this table layout and tabbed structure I’m having the Explorer crash again. I disabled/commented every line of a method block and method call and everything in my source-code to ensure that nothing in my source-code is causing the crash, the problem is with the changes in the UI, with the controls that I added, I don’t know exactly what or why.
Oh my god, how desperate is this thing…
Anyway if needed to analyze, this is the exact source-code that I compiled:
#Region " Option Statements "
Option Strict On
Option Explicit On
Option Infer Off
#End Region
#Region " Imports "
Imports System.ComponentModel
Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Text
Imports System.Windows.Forms
Imports SharpShell.SharpPropertySheet
#End Region
#Region " PropertyPage "
Partial Public Class PropertyPage : Inherits SharpPropertyPage
#Region " Private Fields "
Private filePath As String
Private currentListView As ListView
Private ReadOnly lvItemsProductDict As New Dictionary(Of String, ListViewItem)(20, StringComparer.OrdinalIgnoreCase) From {
{"File Name", New ListViewItem("File Name")},
{"Original Name", New ListViewItem("Original Name")},
{"Product Name", New ListViewItem("Product Name")},
{"Product Description", New ListViewItem("Product Description")},
{"Company Name", New ListViewItem("Company Name")},
{"Copyright", New ListViewItem("Copyright")},
{"File Version", New ListViewItem("File Version")},
{"Product Version", New ListViewItem("Product Version")},
{"Language", New ListViewItem("Language")}
}
Private ReadOnly lvItemsCompilationDict As New Dictionary(Of String, ListViewItem)(20, StringComparer.OrdinalIgnoreCase) From {
{"PE File Kind", New ListViewItem("PE File Kind")},
{"Platform", New ListViewItem("Platform")},
{"Build Configuration", New ListViewItem("Build Configuration")},
{"CLR Version", New ListViewItem("CLR Version")},
{"Target .NET Framework", New ListViewItem("Target .NET Framework")},
{"Entry-Point Address", New ListViewItem("Entry-Point Address")},
{"Root Namespace", New ListViewItem("Root Namespace")},
{"Is Strong-Name Signed", New ListViewItem("Is Strong-Name Signed")},
{"Public Key Token", New ListViewItem("Public Key Token")},
{"Compilation TimeStamp", New ListViewItem("Compilation TimeStamp")}
}
Private ReadOnly lvItemsAttributesDict As New Dictionary(Of String, ListViewItem)(20, StringComparer.OrdinalIgnoreCase) From {
{"Dll Import Search Paths", New ListViewItem("Dll Import Search Paths")},
{"Is CLS Compliant", New ListViewItem("Is CLS Compliant")},
{"Is COM Visible", New ListViewItem("Is COM Visible")},
{"Is Installed in GAC", New ListViewItem("Is Installed in GAC")},
{"Security Permission", New ListViewItem("Security Permission")}
}
Private ReadOnly lvItemsUniqueIdsDict As New Dictionary(Of String, ListViewItem)(20, StringComparer.OrdinalIgnoreCase) From {
{"Assembly GUID", New ListViewItem("Assembly GUID")},
{"MD5 Hash", New ListViewItem("MD5 Hash")},
{"SHA-1 Hash", New ListViewItem("SHA-1 Hash")},
{"SHA-256 Hash", New ListViewItem("SHA-256 Hash")}
}
#End Region
#Region " Constructors "
Public Sub New()
MyClass.InitializeComponent()
Me.Name = My.Application.Info.AssemblyName
Me.PageTitle = Me.Name
' Me.PageIcon = My.Resources.Visual_Studio
End Sub
#End Region
#Region " Event Invocators "
Protected Overrides Sub OnPropertyPageInitialised(ByVal e As SharpPropertySheet)
Me.filePath = e.SelectedItemPaths.Single()
MyBase.OnPropertyPageInitialised(e)
End Sub
#End Region
#Region " Event Handlers "
Private Sub TabControlListViews_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TabControlListViews.SelectedIndexChanged
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CopyToolStripMenuItem.Click
End Sub
Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
End Sub
#End Region
#Region " Private Methods "
Private Sub LoadAssemblyInfo()
End Sub
Private Sub LoadListViewItems(lv As ListView)
End Sub
Private Sub SaveAsTextFile(filePath As String)
End Sub
#End Region
End Class
#End Region
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 39 (26 by maintainers)
Hey all, I can verify/reproduce, problem happens on my system (win10x64 as always), too. Created my Server using precompiled SharpShell v2.7.0 with a form as stated here: https://github.com/dwmkerr/sharpshell/issues/233#issuecomment-437516334
OK, looks tricky. When I get home I’m going to share a way to get better debugging information, will update shortly
Thanks @ElektroStudios - I’ve raised #249, if it looks sane to you let me know and I’ll merge and release!
Just trying to catch up here @ElektroStudios and @Countryen, can you let me know:
I am worried about changing things dynamically in controls, because it doesn’t cover scenarios where clients dynamically create interfaces. But I might have missed some details from the conversation!
@ElektroStudios Okay, tried your fix from https://github.com/dwmkerr/sharpshell/issues/233#issuecomment-439649406 now.
Works fine for me. Same logging, constantly Message: 0x087 w/o the fix/subclass.
@ElektroStudios Okay thanks for the info about the deleted post. No haven’t tried it yet, will in a bit.
Thanks also for the insight on Windows Controls “Windows”. A bit weird to call a “Text Box” a “Window” I guess, but it’s “Windows” after all 😄 I wonder how WPF handles it then.
In case of there is no other better way to fix it, then I think it would be easy for @dwmkerr to determine a TabControl window by its class name which is “SysTabControl32”, and then apply a control style/window extended style or whatever other thing to do with that window to fix this issue, however, what I really want to say is that I think any solution should care about custom user controls and/or 3rd party controls too, that maybe are not a “SysTabControl32” but maybe could have implemented the same factors that makes a TabControl hangs a property sheet.
Anyway, and just to provide more detailed info: I’m checking the .NET Framework class library reference source and what it does when specifiying the ControlStyles.ContainerControl style is apply the WS_EX_CONTROLPARENT (0x00010000L) extended window style flag to the current window:
Weird to me.
Yes seems like the best workaround right now. I am glad we’ve got the same result for once 😉
Maybe dwmkerr knows more about the WindowProc’s and how to fully fix this in the SharpShell code. For a simple fix the
SharpPropertyPagecould probably set the style of all containingTabControls by itself. Or it should deny usage of TabControls until it’s fixed.Okay, I now tested various different Controls. Result: Only if I nest a Control inside a TabControl it crashes. GroupBoxes, FlowLayoutPanel, Panel, etc. all fine with nested controls - just the TabControl is bad for me. Even multi-nesting works fine. I am curious what your result will be.
(Tested w/o any modifcation to the PropertyPageProxy)
So I guess we can focus on the actual TabControl and it’s difference. Maybe because the actual Property Sheet is already a Tab?
For now I’d suggest just building a custom TabControl with panels and buttons or other Controls as a workaround.
Note: If the result is the same for ElektroStudios it would be good to add “TabControl” that to the title of the issue - for future reference.
This is fixing my problem:
return a value different than zero instead of returning zero as the Microsoft docs says. It is working for me, the window is activated and no hang will occur anymore, does not matter If I activate the window by a mouse-click or by ALT+TAB.
I also keep an eye on WM_MOUSEACTIVATE message. Before discovering the workaround above, I tried to return all available values (1, 2, 3 and 4) when processing WM_MOUSEACTIVATE message, but it always hangs. I need to test this with other controls as suggested by @Countryen
@ElektroStudios You don’t think I tested that^^? I was sure that the logging does not infere - because for me it doesnt. I can remove all the logging (just did) and it still works with your Server / Property Sheet.
As soon as I remove
Target.Focus()it crashes(But next time I’ll include the snippet for extra clarity.)
I agree that my “solution” is rather magically and the actual problem is probably not the missing Target.Focus() / Log call.
@dwmkerr I researched some and inspected others Property Sheets (example from Microsoft and TortoiseGit (which I use frequently) for example) and could not find any difference in using WindowProc than the PropertyPageProxy is. They don’t react to neiter 0x0006 nor 0x001C (28).
But yet again, they are not managed and there is little to none information about Managed Property Page Servers out there.
@ElektroStudios can you confirm that it happens with other Controls (maybe multiple layers), too? Maybe some System.Winddows.Forms Controls work and help searching for the actual issue here. I will try some myself. too. Maybe then we can just use different Components/Controls instead until the issue is fixed completely.
@ElektroStudios Downloaded your solution and built it with my SharpShell v2.7 WITH my modification for
WM_ACTIVATEand it runs perfectly fine. Without theTarget.Focus()call it crashes/hangs as expected.This is my log output when using Target.Focus() on leaving the property sheet after focusing the TabControl:
And this is it w/o the Target.Focus() call:
For some reason the second WindowProc is not hit (28, WM_ACTIVATEAPP)
Note when logging this you will see multiple uMessage 32 when hovering the Controls. I omitted these.
This is looking awesome guys, I think we are very close. I will jump in on this one too, just slammed today tomorrow so might be a little behind. I’m trying in the meantime to see if I can find official docs which reference whether certain winproc messages must be handled to safely implement the prop sheet
Before listing uMessages, here is my full VS solution using the SharpShell.dll with the WM_Activation case applied:
( the shell-extension to be registered is the “AssemblyInfo.dll” file inside the “bin\Release” folder. )
maybe could you please check whether it is working for you without any hang/crash?.
Thanks @ElektroStudios - there’s a fix ready to test at #240 now
Great, thanks for the detailed notes! I’ll be on this shortly, I’m just trying to close the registration issues. I think that for the registration issues I have finished the tests which demonstrate the failure:
https://github.com/dwmkerr/sharpshell/pull/240/files#diff-2b093ddbaab14cd3a857fabd7130bac6R95
Although interestingly I cannot actually get the error to manifest on my machine. When I’ve got a fix, would you be able to retest the code before I merge it? Then I’ll get back onto this.