microsoft / CsWinRT

C# language projection for the Windows Runtime
MIT License
543 stars 104 forks source link

Exception in storageLibrary.RequestAddFolderAsync() #1503

Closed 4OTbIPE closed 2 months ago

4OTbIPE commented 7 months ago

Describe the bug System.Runtime.InteropServices.COMException in storageLibrary.RequestAddFolderAsync() or storageLibrary.RequestRemoveFolderAsync()

To Reproduce

  1. Get StorageLibrary via await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
  2. Call RequestAddFolderAsync() on received library

Expected behavior As in the UWP application, an explorer window appears with a folder selection

Version Info WinSDK 10.0.22621 WinAppSDK 1.4.4 Windows 10 Version 21H2 CsWinRT 2.0.7

dongle-the-gadget commented 7 months ago

Is the app packaged?

4OTbIPE commented 7 months ago

Is the app packaged?

yea

manodasanW commented 7 months ago

Is there any detail on the COMException that you got such as the HRESULT / error code?

4OTbIPE commented 7 months ago

Is there any detail on the COMException that you got such as the HRESULT / error code?

I executed this line of code in a clean, newly created WinUI3 application. await (await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures)).RequestAddFolderAsync(); And I got this exception. Exception's message is empty.

   в WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
   в WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
   в ABI.Windows.Storage.IStorageLibraryMethods.RequestAddFolderAsync(IObjectReference _obj)
   в Windows.Storage.StorageLibrary.RequestAddFolderAsync()
   в App2.MainWindow.<myButton_Click>d__1.MoveNext() в C:\Users\alexe\source\repos\App2\App2\App2\MainWindow.xaml.cs:строка 33

изображение

You also can try execute that line of code in clear WinUI3 app. The runFullTrust app. I tried adding Pictures Library to the app's capabilities, but it didn't help. There is a similar problem with RequestRemoveFolderAsync()

4OTbIPE commented 4 months ago

Any news on this please? Can I wait for the fix in the new version with AOT? 2.1 i assume

4OTbIPE commented 2 months ago

@manodasanW any new on this bug, please?

manodasanW commented 2 months ago

I took a look at this. This looks to be an issue with the API itself running on desktop apps. You can find more details and a potential workaround here: https://github.com/microsoft/WindowsAppSDK/issues/4590#issuecomment-2241577125.