IFolderView.SelectAndPositionItems -> MarshalDirectiveException
See original GitHub issueDescribe the bug
Vanara.PInvoke.Shell32.IFolderView (SelectAndPositionItems) Vanara.PInvoke.Shell32.IFolderView2 (SelectAndPositionItems)
System.Runtime.InteropServices.MarshalDirectiveException : ‘Cannot marshal ‘parameter 2’: Invalid managed/unmanaged type combination (Arrays of SafeHandles are not supported).’
What code is involved
...
PIDL[] pIDLs = { pidlsub };
Point[] points = { pt };
FolderView.SelectAndPositionItems(1, pIDLs, points, SVSIF.SVSI_POSITIONITEM);
Expected behavior No MarshalDirectiveException
Note
pidlsub
is valid, and work well with other PIDL related function.
He is from IEnumIdList.Next
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
IFolderView::SelectAndPositionItems (shobjidl_core.h)
Allows the selection and positioning of items visible in the folder's view.
Read more >IFolderView (shobjidl_core.h) - Win32 apps
IFolderView ::SelectAndPositionItems. Allows the selection and positioning of items visible in the folder's view. IFolderView::SelectItem
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for testing my committed code. Glad it works for you. On you second post, I’m not sure what you are freeing with
Marshal.FreeCoTaskMem(pidlSub);
Using the implicit conversion fromIntPtr
toPIDL
on the second line, you are tellingPIDL
to own the pointer and the allocated memory behind it. CallingDispose
on it frees all the memory allocated by the call toIStream_ReadPidl
. Below is how I would have written the loop:That’s what I thought but I was not sure, thank you for clarifying things.
Ho I see, you are using
using
, this way pIDL willDipose()
itself.Thank you for the code cleanup 😃