question

smourier avatar image
0 Votes"
smourier asked SimonMourier-1939 answered

FileOpenPicker.PickSingleFileAsync reports System.OutOfMemoryException on custom namespace extension

Hi,

I'm writing a custom Shell Namespace Extension (as described here: https://docs.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

windows-uwp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Not sure if the custom namespace extension could work with UWP FileOpenPicker. I will need to confirm this first.

0 Votes 0 ·

Hi Roy,

I forgot to say I have it working with PickSaveFileAsync, but not with PickSingleFileAsync.

Simon.

0 Votes 0 ·
RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimonMourier-1939 avatar image
0 Votes"
SimonMourier-1939 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.