-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random exceptions when calling UWP APIs on .NET 5 #640
Comments
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. |
I see that #584 has been fixet. Is it possible to somehow apply this fix without switching to experimental .NET revisions or waiting for .NET 6? |
@a11cf0 , typically once we check in a fix, it will be shipped as part of the next CsWinRT update which will then be used to generate the Windows SDK projection packages and shipped in a .NET 5 update. So your probably won't need to wait till .NET 6 unless the fix is considered a breaking change. But it looks like I am still able to hit the ObjectDisposed exception in your repro even with the fix from the bug I mentioned. We will need to investigate further, but your repro is helpful. |
My call stack is different, but it's an ObjectDisposed when accessing |
I can still hit a random |
@manodasanW I've tried your fix (copying WinRT.Runtime.dll from latest master), but my app is still crashing. Yes confirmed. My issue is still present. Since the exception shows as a native exception and can't be caught at managed side, I think it's probably a WinUI issue instead. |
On .NET 5.0.103 with almost the same test code I no longer get the ObjectDisposedException but the InvalidCastException is now extremely frequent. Previously it was quite rare.
|
@a11cf0 Are you running into the InvalidCastException with the above repro code that you had posted? |
No, but the main part is the same. Here's a complete code sample that throws the exception. I added the loop, because the InvalidCastException is never thrown on the first run.
|
Remaining issue mentioned here is tracked by #762 |
Original author @a11cf0 . Transferred from dotnet/runtime#46148
Description
I'm trying to call Windows 10 UWP OCR APIs from a .NET 5 Windows Forms application. The code which i'm using was perfectly working on .NET Core 3.1 but on .NET 5 it's extremely unstable. For some reason the code throws either ObjectDisposedException or sometimes InvalidCastException. this usually happens on the call to GetSoftwareBitmapAsync() but sometimes right on the first await. Also, hen wrapped in a method, it usually works on the first run but on subsequent runs it fails as above. Here's a full code sample tested on both .NET Core 3.1 and .NET 5 with the above results.
Configuration
I'm using .NET 5.0.101 on Windows 10 X64 10.0.19042.
Regression?
Yes. Everything is working on .NET Core 3.1.
Other information
The text was updated successfully, but these errors were encountered: