ReactiveUI icon indicating copy to clipboard operation
ReactiveUI copied to clipboard

Creating an automatic data template fails, if the UI dispatcher changes

Open flagbug opened this issue 8 years ago • 1 comments

I'm on WinRT and have created an app that is a share target

It seems like each time the app is opened as share target, it gets assigned a new UI dispatcher, while the AppDomain persists.

This is a problem, when creating the automatic DataTemplate at https://github.com/reactiveui/ReactiveUI/blob/3f725c808b1d4c8457f0d3204e0a071aa462cd75/ReactiveUI/Xaml/AutoDataTemplateBindingHook.cs#L26, since it's lazy and persists over the AppDomain and the first UI dispatcher gets cached in the DataTemplate.

When the dispatcher then changes, and the template with the old dispatcher is assigned to a control that was created on the new UI thread, line https://github.com/reactiveui/ReactiveUI/blob/3f725c808b1d4c8457f0d3204e0a071aa462cd75/ReactiveUI/Xaml/AutoDataTemplateBindingHook.cs#L67 will result in a weird COM exception "COM object that has been separated from its underlying RCW cannot be used" (At least on WinRT)

flagbug avatar Oct 05 '15 11:10 flagbug

Maybe we can use https://msdn.microsoft.com/en-us/library/dd642243(v=vs.110).aspx here, so we get a new data template for each thread

flagbug avatar Dec 29 '15 09:12 flagbug

Fixed in 19.4.1, XAML parser issue was located Uwp project has been retired fix is present in WinUI.

ChrisPulman avatar Jul 12 '23 07:07 ChrisPulman

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.

github-actions[bot] avatar Jul 27 '23 00:07 github-actions[bot]