Skip to content

FolderPicker Not working in 1.8-preview with SelfContained: Element not found. #5749

Closed

Description

Describe the bug

i want to use FolderPicker but i get exception Element not found.

var picker = new Microsoft.Windows.Storage.Pickers.FolderPicker(App.MainWindow.AppWindow.Id);
var result = await picker.PickSingleFolderAsync();

Steps to reproduce the bug

1.Pick a Folder
2.Use SelfContained
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.8 Preview 1: 1.8.250814004-preview1

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 (26100, June 2025 Update)

IDE

Visual Studio 2022-preview

Additional context

Dinah Xiaoman G (@DinahK-2SO)

Activity

  1. DarranRowe commented on Aug 24, 2025

    @DarranRowe

    I'm not actually seeing this when using the pickers from a C++ Windows API application.

    I am seeing noisy debug output along the lines of:

    onecoreuap\internal\shell\inc\SrcPkg\FileExplorerSessionWatcher\inc\FileExplorerSessionWatcher.h(1819)\SHELL32.dll!00007FF95AACF5D8: (caller: 00007FF95A9DA9F2) ReturnHr(1) tid(3790) 80004001 Not implemented
    shell\SrcPkg\FileExplorer\DefView\src\DefView.cpp(17814)\SHELL32.dll!00007FF95A9DAA11: (caller: 00007FF92D842F4F) LogHr(1) tid(3790) 80004001 Not implemented
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\urlmon.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\iertutil.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\Windows.System.Launcher.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\IconCodecService.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\policymanager.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110_win.dll'. Symbols loaded without source information.
    onecoreuap\internal\shell\inc\SrcPkg\FileExplorerSessionWatcher\inc\FileExplorerSessionWatcher.h(1819)\SHELL32.dll!00007FF95AACF5D8: (caller: 00007FF95A9DA9F2) ReturnHr(2) tid(3790) 80004001 Not implemented
    shell\SrcPkg\FileExplorer\DefView\src\DefView.cpp(17814)\SHELL32.dll!00007FF95A9DAA11: (caller: 00007FF92D842F4F) LogHr(2) tid(3790) 80004001 Not implemented
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\d2d1.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\d3d10warp.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\DXCore.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\ResourcePolicyClient.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Unloaded 'C:\Windows\System32\ResourcePolicyClient.dll'
    'WinTest.exe' (Win32): Loaded 'C:\Windows\System32\directxdatabasehelper.dll'. Symbols loaded without source information.
    'WinTest.exe' (Win32): Unloaded 'C:\Windows\System32\d3d10warp.dll'
    'WinTest.exe' (Win32): Unloaded 'C:\Windows\System32\msftedit.dll'
    shell\explorerframe\navbar.cpp(82)\explorerframe.dll!00007FF92D93AE15: (caller: 00007FF92D827A3E) LogHr(1) tid(3790) 80070057 The parameter is incorrect.
    The thread 30340 has exited with code 0 (0x0).
    C:\__w\1\s\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\include\wil\result.h(958)\Microsoft.WindowsAppRuntime.dll!00007FF8481CB30C: (caller: 00007FF8481FD7FD) LogHr(1) tid(6ecc) 8007029C An assertion failure has occurred.
    

    But otherwise the pickers are seemingly working correctly. This is framework dependent and I have tested both packaged and unpackaged.

    The code that I am using to use the folder picker is:

    	void main_window::on_lbuttonup(window_base::windowing::mouse_vkey, int32_t, int32_t)
    	{
    		[](winrt::Microsoft::UI::WindowId id) -> winrt::Windows::Foundation::IAsyncAction
    			{
    				winrt::Microsoft::Windows::Storage::Pickers::FolderPicker fp{ id };
    				auto result = co_await fp.PickSingleFolderAsync();
    				co_return;
    			}(winrt::Microsoft::UI::GetWindowIdFromWindow(get_handle()));
    	}
    

    So, does this also happen in a WPF/WinForms application? Is your application self contained? Are you attempting to apply the workaround for experimental?

  2. Sella-GH commented on Aug 24, 2025

    @Sella-GH

    Does your StackTrace by chance include something about Microsoft.Windows.ApplicationModel.Resources? I get the Element Not Found COM Exception too but it's because somehow my .resw files aren't imported into the project.

  3. ghost1372 commented on Aug 24, 2025

    @ghost1372
    ContributorAuthor

    Thank you DarranRowe
    The issue originates from this line.

    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
    can you tell me about workaround?

  4. changed the title [-]FolderPicker Not working in 1.8-preview Element not found.[/-] [+]FolderPicker Not working in 1.8-preview with SelfContained: Element not found.[/+] on Aug 24, 2025
  5. DarranRowe commented on Aug 24, 2025

    @DarranRowe

    Mahdi Hosseini (@ghost1372)

    The one documented in the experimental 4 release notes.

    Well, if the project is set to self contained and is using the project that has the integrated packaging stuff, then this happens. If the project is an external packaging project then everything seems to work fine, even when EnableMsixTooling is set to true.

    Final edit.

    After looking through the directory, I noticed that there was a discrepancy in the files in the directory between the single project packaging project and the external packaging project. After looking through and copying some files over that really mattered, (no .xbf files since the single project packaging embeds these even in the debug configuration) it worked. So the single project packaging is missing files that the external packaging project is copying. I haven't put too much effort into figuring out which file is the real problem, but it is the single project packaging that is the cause of this.

  6. ghost1372 commented on Aug 25, 2025

    @ghost1372
    ContributorAuthor

    DarranRowe i could not find Microsoft.WindowsAppRuntime.pri, and my project is a Single MSIX Project, however i tested project in UnPackaged mode and it is worked fine!

  7. optsing commented on Aug 25, 2025

    @optsing

    DarranRowe wait, there is a known issue in experemental4 that dialogs don't work in non-self-contained, but now they don't work in self-contained.

  8. DarranRowe commented on Aug 25, 2025

    @DarranRowe

    optsing

    They work with self contained without issue if the project is unpackaged or it is packaged and you are using the separate packaging project.

    Mahdi Hosseini (@ghost1372)

    If the absence of that file is causing a problem, then this would be unexpected in its own right. The resources in Microsoft.WindowsAppRuntime.pri are being merged into the package's resources.pri. It is expected that the resources should be found in there.

  9. added
    area-File access
    on Aug 25, 2025
  10. DinahK-2SO commented on Aug 27, 2025

    @DinahK-2SO
    Contributor

    Thanks Mahdi Hosseini (@ghost1372) for reporting this issue. It is caused by the missing *.pri files - they were not included in the App package.

    We also discovered and reported this issue internally, tagging Scott Jones (@Scottj1s) and Manodasan Wignarajah (@manodasanW) here.

  11. manodasanW commented on Aug 30, 2025

    @manodasanW
    Member

    This should be resolved with Microsoft.Windows.SDK.BuildTools.MSIX 1.7.20250829.1. WinAppSDK will be updated to reference that but you can try referencing it directly to confirm if it resolves your issue.

  12. manodasanW commented on Sep 9, 2025

    @manodasanW
    Member

    This is fixed in WinAppSDK 1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-File access

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions