-
Notifications
You must be signed in to change notification settings - Fork 199
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
Read-only ShellItemPropertyStore throws System.Runtime.InteropServices.COMException - GPS_BESTEFFORT flag resolves issue #378
Comments
Since you have this running, would you mind testing the following? using var item = new ShellItem(path);
using var propertyDescriptions = item.GetPropertyDescriptionList();
propertyDescriptions.ReadOnly = false;
foreach (var description in ... |
I'm assuming you mean: using var item = new ShellItem(path);
using var propertyDescriptions = item.GetPropertyDescriptionList();
item.Properties.ReadOnly = false;
foreach (var description in ... Since there's no ReadOnly property on PropertyDescriptionList*. This throws:
For that same file. *(That's on me, really. Sorry for the slightly wonky example using keys from PropertyDescriptionList to access the ShellItemPropertyStore - I was working backwards from some other attempts at resolving the issue when I wrote that example.) Some other things I've tried:
|
I made a change to |
Describe the bug and how to reproduce
Sometimes, attempting to retrieve a property from a ShellItem will result in a System.Runtime.InteropServices.COMException.
(Using
ShellItem.Properties.GetValueOrDefault
)I've noticed this happening with
.exe
files most often (e.g., reading the items in a WinPython or Adobe Acrobat Reader install directory), though it's not consistent and I haven't been able to find the common thread between them.No current configuration of
ShellItemPropertyStore
seems to resolve the issue. However, creating a read-only PropertyStore with theGPS_BESTEFFORT
flag (instead of the currentGPS_DEFAULT
) does work.What code is involved
https://github.com/dahall/Vanara/blob/master/Windows.Shell.Common/ShellProperties/ShellItemPropertyStore.cs
For comparison, the following code results in a COMException* when tested against certain files (for instance,
AdobeGenuineSlimInstaller.exe
from an Acrobat Reader DC installation):Whereas this does not:
*The specific exception is:
Expected behavior
The intention of this code was to replace a PowerShell script which performed
ShellFolder.GetDetailsOf
calls.GetDetailsOf would consistently succeed, where
ShellItem.Properties
would throw an exception.I would prefer
ShellItemPropertyStore
to safely retrieve properties, or at least provide a means of setting theGPS_BESTEFFORT
flag without also settingReadOnly
to false.The text was updated successfully, but these errors were encountered: