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

Problems with ShellNamespaceTreeControl #153

Closed
tajbender opened this issue Jul 26, 2020 · 21 comments
Closed

Problems with ShellNamespaceTreeControl #153

tajbender opened this issue Jul 26, 2020 · 21 comments

Comments

@tajbender
Copy link
Contributor

Hello David,

I just wanted to integrate ShellNamespaceTreeControl but found issues:

1. When using the Designer, I get the following MessageBox:

ShellNamespaceTreeControl - Designer

This happens after dropping the Control onto its form in the Designer, and hitting Start the first time.

2. AccessViolationException:

Describe the bug
While playing around with the TreeView, trying to expand this and that Node, I sometimes get an AccessViolationException. This isn't often the case, about 20-30 tries that went okay before the exception occurs.

Don't think it has to do with a specific folder type, and when, I couldn't find the pattern this makes it happen.

Here is the debugger's "View Details" output:

  Name Value Type
$exception {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."} System.AccessViolationException
  ▶ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
  HResult 0x80004003 int
  HelpLink null string
  IPForWatsonBuckets 0x00000000 System.UIntPtr
  ▶ InnerException null System.Exception
  IsTransient false bool
  Message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." string
  RemoteStackTrace null string
  Source "System.Windows.Forms" string
  StackTrace " at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at Vanara_ShellNamespaceTreeControl.Program.Main() in S:\[Git.Workspace]\[Test-Projekte]\Vanara-ShellNamespaceTreeControl\Program.cs:line 19" string
  ▶ TargetSite {IntPtr DispatchMessageW(MSG ByRef)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
  ▶ WatsonBuckets {byte[0x000015f0]} object {byte[]}
  _HResult 0x80004003 int
  _accessType 0x00000000 int
  _className null string
  ▶ _data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
  _dynamicMethods null object
  _exceptionMethod null System.Reflection.MethodBase
  _exceptionMethodString null string
  _helpURL null string
  ▶ _innerException null System.Exception
  _ip 0x65ce2f9f System.IntPtr
  _ipForWatsonBuckets 0x00000000 System.UIntPtr
  _message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." string
  _remoteStackIndex 0x00000000 int
  _remoteStackTraceString null string
  ▶ _safeSerializationManager {System.Runtime.Serialization.SafeSerializationManager} System.Runtime.Serialization.SafeSerializationManager
  _source "System.Windows.Forms" string
  ▶ _stackTrace {sbyte[0x000000c0]} object {sbyte[]}
  _stackTraceString null string
  _target 0x00000024 System.IntPtr
  ▶ _watsonBuckets {byte[0x000015f0]} object {byte[]}
  _xcode 0xc0000005 int
  _xptrs 0x00bad36c System.IntPtr
  ◢ Static members    
  _COMPlusExceptionCode 0xe0434352 int
  s_EDILock {object} object

What code is involved

Just a plain Windows Forms window, nothing in it except the ShellNamespaceTreeControl. BTW, this also happened to me using the Unit Test App.

Using Vanara v3.2.12, .net Framework 4.6 on a Windows 10 machine.

Thank you very much in advance, regards,

tajbender

@dahall
Copy link
Owner

dahall commented Jul 26, 2020

I think I addressed the first problem with a property decoration. However, using the unit test app I cannot replicate the second issue. I've expanded and contracted system folders, namespace folders, zip files, etc. on my system about 50 times and never see an exception. If you're able to reproduce with consistency, please let me know how.

@tajbender
Copy link
Contributor Author

Thanks for your quick reply.

In the meantime I found the second issue only arises when built in Debug configuration and being run within the VS-Debugger. Using release config wipes the bug away...

Nice, I love those bugs. Enable native code debugging brought those additional Infos, I'm not to confident they'll help you, but perhaps you have any idea - I don't 😞

Exception thrown at 0x66252F9F (comctl32.dll) in ExplorerBrowser.exe: 0xC0000005: Access violation reading location 0x00000024.

@dahall
Copy link
Owner

dahall commented Jul 28, 2020

I can't replicate it, even with your instructions. Since I think I fixed your first issue (please confirm) with the release yesterday, let me know if I can close this.

@tajbender
Copy link
Contributor Author

Sure you can close this. Any Ideas what I can do to narrow the problem on my machine down?

@dahall
Copy link
Owner

dahall commented Jul 29, 2020

It is interesting to look at the logs. It appears the fault is in ComCtl32.dll, which is the hosting dll for the underlying TreeView control. That makes me think it may have something to do with message handling (or event handling in the COM wrapper). I'll take a closer look at anything in my code in that space, but it is pretty light. It may be a problem with the INameSpaceTreeControl implementation. I'll leave this open and let you know what I find.

@tajbender
Copy link
Contributor Author

Thank you so much. In the meantime, I'll also do some deeper investigations and will let you know if I have any more idea.

However, David, please don't spend too much of your time while digging into this. Perhaps it's my machine that suffers of some kind of bad configuration, although it's a very clean developer machine with TortoiseGIT, Visual Studio, Kaspersky AV and some more development tools, sort of nothing special.

However, thanks for supporting me.

@tajbender
Copy link
Contributor Author

tajbender commented Aug 2, 2020

@dahall: I have an Idea: Originally, I placed the Tree into a SplitContainer. Now I removed the surrounding SplitContainer, et voila. As far I can tell now, after some minutes of testing, it works at least much more stable es before.. Any ideas on this?

Are System.Windows.Forms.SplitContainer Controls buggy as hell? I didn't use them too much, to be honest.

However, I'm very sorry for bothering you with this :(

EDIT: Although that doesn't clarify why the test-app is crashing on my machine 😡

@tajbender
Copy link
Contributor Author

tajbender commented Aug 3, 2020

@dahall: Now, I'm almost pretty sure, about 50% 😞, it has to do with Dock property. As soon as I set the Dock-Property to Left, Right, Top, Bottom, Fill problems arise and I get hard crashes. Reverting back to DockStyle.None and it works as expected.

Can you confirm this on your machine?

@dahall
Copy link
Owner

dahall commented Aug 3, 2020

My testing app has Dock = Fill and it works without error even with automated testing that changes the form size 50 times and selects 50 items. Sorry.

@tajbender
Copy link
Contributor Author

Hi David, what Framework version are you using for your testing?

@dahall
Copy link
Owner

dahall commented Aug 3, 2020

4.5.2

@tajbender
Copy link
Contributor Author

Okay, thank you very much so far. I'll reinstall my machine eventually and hope this will help.

Thank you very much!

@dahall
Copy link
Owner

dahall commented Aug 3, 2020

I was doing some testing on the events today and found that a number of them return a seemingly wrong value to the interface. I'm playing with values now since the docs are not very good. I'll let you know when I have something to test.

@dahall
Copy link
Owner

dahall commented Aug 3, 2020

I can't figure out how, but I just got your exception. I'm opening this up until I can figure it out.

@dahall dahall reopened this Aug 3, 2020
@tajbender
Copy link
Contributor Author

tajbender commented Aug 6, 2020

Maybe it's just an InvokeRequired(), that's missing somewhere? Just a thought.

By the way, how can I cast a Shell32.ShellFolder object into an IShellFolder? IShellFolder member is protected as you know, so how do I get it?

@dahall
Copy link
Owner

dahall commented Aug 6, 2020

I've had to redo much of the ShellNamespaceTreeControl class and am still working through one final bug.

On you second question, there wasn't a way to get the underlying IShellFolder instance. I just added a property to allow it.

dahall added a commit that referenced this issue Aug 6, 2020
… (keyboard movement could be improved), but much better.
@dahall
Copy link
Owner

dahall commented Aug 6, 2020

It's working much better now, but I wouldn't consider it "production". If you really need it and have time to work on it, please submit a PR.

@dahall dahall closed this as completed Aug 6, 2020
@dahall
Copy link
Owner

dahall commented Aug 7, 2020

If you have time, please give the update a test. You can add https://ci.appveyor.com/nuget/vanara-prerelease to your NuGet package repository list and then pull the 3.2.14 packages.

@tajbender
Copy link
Contributor Author

Hello David,

thank you so much! I've played around with this version and it works much more stable now. Great work!

However, I found one (small) Issue: When navigating to a sub-folder of Desktop\Libraries in the Tree, like Desktop\Libraries\Documents or Desktop\Libraries\Pictures, I get an exception when accessing the SelectedItem:

System.IO.FileLoadException
HResult=0x80070020
Message=The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
Source=
StackTrace:

Any Idea? Thank you very much again, and have I nice weekend 🌞

Regards,
tajbender

@tajbender
Copy link
Contributor Author

It's working much better now, but I wouldn't consider it "production". If you really need it and have time to work on it, please submit a PR.

Okay, I'll investigate this. Thank you so much!

@dahall
Copy link
Owner

dahall commented Aug 20, 2020

This is now officially published to NuGet

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

No branches or pull requests

2 participants