FileOpenPicker.PickSingleFileAsync reports System.OutOfMemoryException on custom namespace extension

Anonymous
2019-11-27T18:27:09.97+00:00

Hi,

I'm writing a custom Shell Namespace Extension (as described here: https://learn.microsoft.com/en-us/windows/win32/shell/nse-works) but when I use UWP's FileOpenPicker and try to pick a file (browsing works fine) it reports an OutOfMemoryException error once I select a file. I'm using the FilePicker sample from github.

FileOpenPicker works with the standard file system files. My question is what should I have to add or change to my namespace extension so it works?

BTW, my extension supports standard Common Dialogs (IFileDialog) fine with regular Win32/64 apps (like Office, notepad, etc.)

Thanks

Universal Windows Platform (UWP)
{count} votes

2 answers

Sort by: Most helpful
  1. Roy Li - MSFT 31,766 Reputation points Microsoft Vendor
    2019-12-03T02:00:18.473+00:00

    Hi,

    Welcome to the Microsoft Q&A platform!

    After confirming with the team, we are sure that the custom shell extensions don't work for UWP apps. UWP apps are using file broker when accessing files in the system. But it is not allowed to load non-signed into the file broker.

    0 comments No comments

  2. Simon Mourier 1 Reputation point
    2019-12-03T07:08:29.98+00:00

    Hi Roy,

    I'm not sure exactly what you mean by a "file broker" and "load non-signed into the file broker" (is this documented anywhere?).

    UWP apps pick files using the FileOpenPicker class, and this class works through a Windows-provided PickerHost.exe process. And I can't assure you that this PickerHost.exe process does load any custom SNE - Shell Namespace Extension - again through standard Windows's Common Dialogs, IFileDialog interfaces in its process.

    It's loaded when one uses PickSingleFileAsync (File Open) and PickSaveFileAsync (File Save As). Again, I can confirm this is not a guess, it's a fact. When a UWP app (such as the FilePicker sample) calls these API, a custom SNE is loaded in the PickerHost.exe process.

    So, maybe what you mean is a custom SNE won't be loaded into the app process itself, and yes, if this what's you mean, you're right, but it quite irrelevant.

    As I told in my remark, it works fine with PickSaveFileAsync (Save As). It's just with PickSingleFileAsync (File Open) that it reports this OutOfMemoryException (please note is not a security nor package identity error).

    So, IMHO, either UPW apps have a pretty serious security issue (as you say this shouldn't be allowed at all), either the PickSingleFileAsync case should be investigated more.

    0 comments No comments