-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
[BUG] Splat.Microsoft.Extensions.DependencyInjection causes System.InvalidOperationException: Call from invalid thread #1024
Comments
I'm guessing what's happening is Avalonia is sensitive that the logic in Part of the The Avalonia team maintain their own RxUI plugin but I'd imagine they might have a extension to convert an observable to run on the main ui thread. |
Thanks for the quick response @glennawatson! Why do you reckon it doesn't happen when using Splat's built-in resolver? |
Same issue with Splat.DryIoc. |
Splat tends to be a dictionary based system that creates on whatever thread is calling it. So it'll call a Func method, so could be to do with that. I can have a look later today. |
I used a Func for MS DI (you can see it in the repro code) but not with DryIoc. This is the code:
Happy to do some debugging if you point me in the right direction. |
Let me have a look properly tomorrow for you. We are in the same Timezone. @ChrisPulman may have time in our evenings if life permits. |
I can try to take a look this evening, having the repo is really helpful, thank you. |
AvaRxUI_V2.zip |
AvaloniaUI/Avalonia#12261 |
Avalonia have decided that they don't want to add the suggested packages to their codebase. |
I guess we could take the hit somewhere in the rxui repo so it's more official. |
Discussed with @ChrisPulman offline, we'll make official Splat packages supporting the Avalonia use case for the different DI containers. It'll be minimal invasive to our stuff. |
Thanks @ChrisPulman & @glennawatson, much appreciated! Just a couple of things after looking at the code:
|
The end Splat packages will be a single alternative package for Avalonia and not an additional one, and be an extension of the existing code with a single dll. RxApp.MainThreadScheduler should be set to AvaloniaScheduler.Instance and is done in the UseReactiveUI section of Avalonia.ReactiveUI, however when initialisation of Splat with the new DI occurs the RxApp.MainThreadScheduler is reset causing the issue you experienced. |
The following packages have been released: Each is a single dll that replaces the need to include either Avalonia.ReactiveUI or the relevant Splat container package. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Just trying to put together Avalonia's routing sample and Splat.Microsoft.Extensions.DependencyInjection. Pressing Go next button throws the exception below when Splat.Microsoft.Extensions.DependencyInjection is used. Works fine if
services.UseMicrosoftDependencyResolver();
is commented out.Repro: AvaRxUI.zip
The text was updated successfully, but these errors were encountered: