question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StorageFile.CreateStreamedFileAsync throws wrong thread exception

See original GitHub issue

Describe the bug

var storageFile = await StorageFile.CreateStreamedFileAsync("test.png", OnStorageFileNeeded, null)

throws a COMException with is claiming to be on the wrong thread. This is happening for me on the UI thread, which I think should work and has worked in WinUI 2. (I have some difficulty in providing more information, as for me VisualStudio 2019 16.10 Preview 2.1 becomes completely unresponsive when this exception is encountered. Restarting explorer.exe enabled me to recover from this exception.)

Expected behavior Should not throw exception, this was working in UWP / WinUI 2.

Version Info

NuGet package version: WinUI 3 - Project Reunion 0.5: 0.5.5

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Marv51commented, Jun 23, 2021

This seems to be working now 🥳

0reactions
manodasanWcommented, May 1, 2021

I believe this is the same issue as https://github.com/microsoft/CsWinRT/issues/612 . I am able to repro to this issue and should able to confirm whether my fix resolves it or not once I am done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StorageFile.CreateStreamedFileAsync Method
This method lets the app produce the data on-demand by specifying a function to be invoked when the StorageFile that represents the stream...
Read more >
c# - Wrong Thread Exception when changing an object's ...
It throws a WRONG_THREAD exception. It's the same for all these other events. I also tried using the await CoreApplication.MainView.
Read more >
[Solved]-UWP share feature not working in Windows 10 ...
it seems that createstreamedfileasync method does not work properly with share contract in mobile. we've logged this issue internally and i will update...
Read more >
StorageFile.OpenStreamForReadAsync, Windows.Storage ...
Storage.StorageFile class is used to open a stream for reading the contents of a file asynchronously. This method returns a System.Threading.Tasks.Task object ...
Read more >
FTP Endeavor II – Upload and Download Files - Can Bilgin
Using the StorageFile abstraction, we can easily make the ftp ... throw new FtpException( string . ... CreateStreamedFileAsync(path.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found