You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.ComWrappersSupport.CreateCCWForObjectForABI(Object obj, Guid iid)
at WinRT.ComWrappersSupport.CreateCCWForObjectForMarshaling(Object obj, Guid iid)
at WinRT.MarshalInspectable`1.CreateMarshaler2(T o, Guid iid, Boolean unwrapObject)
at WinRT.MarshalInterface`1.CreateMarshaler2(T value, Guid iid)
at ABI.Microsoft.UI.Xaml.Interop.WinRTNotifyCollectionChangedEventArgsRuntimeClassFactory.CreateInstanceWithAllParameters(NotifyCollectionChangedAction action, IList newItems, IList oldItems, Int32 newIndex, Int32 oldIndex)
at ABI.System.Collections.Specialized.NotifyCollectionChangedEventArgs.CreateMarshaler2(NotifyCollectionChangedEventArgs value)
at ABI.System.Collections.Specialized.NotifyCollectionChangedEventHandler.NativeDelegateWrapper.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Abc.Core.ObservableCollectionEx`1.AddRange(IEnumerable`1 collection)
When AOT is disabled there is no exception thrown (even if publishing trimmed).
Thanks, is it a list of that you are constructing (i.e. new List<Person>()) or an array or collection expression? It might be worth trying out the latest CsWinRT 2.2.0 release as we do have improved error messages which should say the type name when InvalidCastException happens. This release has not shipped as the default yet in the .NET SDK, so you would need to explicitly specify it to try it out.
Description
InvalidCastException
"Specified cast is not valid." when<PublishAot>true</PublishAot>
and calling AddRange, which in turn callsStack trace (also see screenshot below)
When AOT is disabled there is no exception thrown (even if publishing trimmed).
Steps To Reproduce
<PublishAot>true</PublishAot>
ObservableCollectionEx
from hereAddRange
methodExpected Behavior
No exception thrown.
Version Info
Additional Context
The text was updated successfully, but these errors were encountered: