Skip to content
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

[WinUI] DispatcherCompat.Schedule throws InvalidCastException on windows #685

Closed
eriklimakc opened this issue Jul 31, 2023 · 2 comments
Closed
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working

Comments

@eriklimakc
Copy link
Contributor

eriklimakc commented Jul 31, 2023

Current behavior

Instance methods calls like _canvas.GetDispatcherCompat().Schedule(_canvas.InvalidateMeasure)
causes a cast exception on Windows:

InvalidCastException: 'Specified cast is not valid.'

Affected platform(s): Windows (WinUI)

@eriklimakc eriklimakc added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Jul 31, 2023
@eriklimakc
Copy link
Contributor Author

Should be made with lambda expression:

_canvas.GetDispatcherCompat().Schedule(()=> _canvas.InvalidateMeasure())
owner.GetDispatcherCompat().Schedule(()=> owner.InvalidateMeasure())

@Xiaoy312 Xiaoy312 added control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag and removed triage/untriaged Indicates an issue requires triaging or verification. labels Jul 31, 2023
@Xiaoy312 Xiaoy312 changed the title [Win] DispatcherCompact Schedule handler incompatibility [WinUI] DispatcherCompat.Schedule throws InvalidCastException Jul 31, 2023
@Xiaoy312 Xiaoy312 changed the title [WinUI] DispatcherCompat.Schedule throws InvalidCastException [WinUI] DispatcherCompat.Schedule throws InvalidCastException on windows Jul 31, 2023
@eriklimakc
Copy link
Contributor Author

eriklimakc commented Jul 31, 2023

Call Stack:

WinRT.Runtime.dll!WinRT.IObjectReference.AsValue(System.Guid iid)    Unknown
WinRT.Runtime.dll!WinRT.MarshalDelegate.CreateMarshaler2(object o, System.Guid delegateIID, bool unwrapObject)    Unknown
Microsoft.InteractiveExperiences.Projection.dll!ABI.Microsoft.UI.Dispatching.DispatcherQueueHandler.CreateMarshaler2(Microsoft.UI.Dispatching.DispatcherQueueHandler managedDelegate)    Unknown
Microsoft.InteractiveExperiences.Projection.dll!ABI.Microsoft.UI.Dispatching.IDispatcherQueueMethods.TryEnqueue(WinRT.IObjectReference _obj, Microsoft.UI.Dispatching.DispatcherQueuePriority priority, Microsoft.UI.Dispatching.DispatcherQueueHandler callback)    Unknown
Microsoft.InteractiveExperiences.Projection.dll!Microsoft.UI.Dispatching.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority priority, Microsoft.UI.Dispatching.DispatcherQueueHandler callback)    Unknown
Uno.Toolkit.WinUI.dll!Uno.Toolkit.UI.DispatcherCompat.Schedule(Uno.Toolkit.UI.DispatcherCompat.Priority priority, Microsoft.UI.Dispatching.DispatcherQueueHandler handler) Line 100    C#
Uno.Toolkit.WinUI.dll!Uno.Toolkit.UI.DispatcherCompat.Schedule(Microsoft.UI.Dispatching.DispatcherQueueHandler handler) Line 96    C#
Uno.Toolkit.Skia.WinUI.dll!Uno.Toolkit.UI.ShadowContainer.UpdateCanvasSize(double childWidth, double childHeight, Uno.Toolkit.UI.ShadowCollection shadows) Line 204    C#
Uno.Toolkit.Skia.WinUI.dll!Uno.Toolkit.UI.ShadowContainer.OnContentSizeChanged(object sender, Microsoft.UI.Xaml.SizeChangedEventArgs args) Line 175    C#
Microsoft.WinUI.dll!WinRT._EventSource_global__Microsoft_UI_Xaml_SizeChangedEventHandler.EventState.GetEventInvoke.AnonymousMethod__1_0(object sender, Microsoft.UI.Xaml.SizeChangedEventArgs e)    Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.SizeChangedEventHandler.Do_Abi_Invoke(nint thisPtr, nint sender, nint e)    Unknown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants