Vanara: Problems with ShellNamespaceTreeControl

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

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.

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

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.