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

Specified cast is not valid. #269

Closed
azchohfi opened this issue May 12, 2020 · 1 comment · Fixed by #273
Closed

Specified cast is not valid. #269

azchohfi opened this issue May 12, 2020 · 1 comment · Fixed by #273
Labels
fixed Issue has been fixed in an upcoming or existing release

Comments

@azchohfi
Copy link
Contributor

System.InvalidCastException
  HResult=0x80004002
  Message=Specified cast is not valid.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

  This exception was originally thrown at this call stack:
   at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr) in d:\a\1\s\WinRT.Runtime\ExceptionHelpers.cs:line 69
   at ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.OnItemsChanged(Object e) in E:\BA\13\s\BuildOutput\obj\amd64fre\MergedWinMD\private\generated\Microsoft.UI.Xaml.Controls.cs:line 110218
   at Microsoft.UI.Xaml.Controls.ItemsControl.OnItemsChanged(Object e) in E:\BA\13\s\BuildOutput\obj\amd64fre\MergedWinMD\private\generated\Microsoft.UI.Xaml.Controls.cs:line 22673
   at Microsoft.UI.Xaml.Controls.ItemsControl.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.OnItemsChanged(Object e) in E:\BA\13\s\BuildOutput\obj\amd64fre\MergedWinMD\private\generated\Microsoft.UI.Xaml.Controls.cs:line 22675
   at ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.Vftbl.Do_Abi_OnItemsChanged_4(IntPtr thisPtr, IntPtr e) in E:\BA\13\s\BuildOutput\obj\amd64fre\MergedWinMD\private\generated\Microsoft.UI.Xaml.Controls.cs:line 110043

This is the Line that throws:
https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/winui/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AdaptiveGridView/AdaptiveGridViewPage.xaml.cs#L29

Full stack:

 	ntdll.dll!00007ffb66e13d74()	Unknown
 	KernelBase.dll!00007ffb646f270e()	Unknown
 	ntdll.dll!00007ffb66e1909f()	Unknown
 	ntdll.dll!00007ffb66db70ec()	Unknown
 	ntdll.dll!00007ffb66e17bae()	Unknown
 	KernelBase.dll!00007ffb646f361c()	Unknown
 	[Managed to Native Transition]	
>	WinRT.Runtime.dll!WinRT.ExceptionHelpers.ThrowExceptionForHR(int hr) Line 69	C#
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.OnItemsChanged(object e) Line 110218	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.ItemsControl.OnItemsChanged(object e) Line 22673	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.ItemsControl.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.OnItemsChanged(object e) Line 22675	C#
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.Vftbl.Do_Abi_OnItemsChanged_4(System.IntPtr thisPtr, System.IntPtr e) Line 110043	C#
 	[Native to Managed Transition]	
 	Microsoft.UI.Xaml.dll!std::_Func_impl_no_alloc<<lambda_dc10856245d8caeaea0c3cee446e8e47>,long,ABI::Windows::Foundation::Collections::IObservableVector<IInspectable *> *,ABI::Windows::Foundation::Collections::IVectorChangedEventArgs *>::_Do_call(ABI::Windows::Foundation::Collections::IObservableVector<IInspectable *> * && <_Args_0>, ABI::Windows::Foundation::Collections::IVectorChangedEventArgs * && <_Args_1>) Line 926	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!std::_Func_class<long,ABI::Microsoft::UI::Xaml::IUIElement *,ABI::Microsoft::UI::Xaml::IBringIntoViewRequestedEventArgs *>::operator()(ABI::Microsoft::UI::Xaml::IUIElement * <_Args_0>, ABI::Microsoft::UI::Xaml::IBringIntoViewRequestedEventArgs * <_Args_1>) Line 976	C++
 	Microsoft.UI.Xaml.dll!ctl::event_handler_base<ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::UI::Xaml::UIElement *,ABI::Microsoft::UI::Xaml::BringIntoViewRequestedEventArgs *>,ABI::Microsoft::UI::Xaml::IUIElement,ABI::Microsoft::UI::Xaml::IBringIntoViewRequestedEventArgs,DirectUI::UIElementBringIntoViewRequestedTraits>::Invoke(ABI::Microsoft::UI::Xaml::IUIElement * pSender, ABI::Microsoft::UI::Xaml::IBringIntoViewRequestedEventArgs * pArgs) Line 37	C++
 	Microsoft.UI.Xaml.dll!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,ABI::Windows::Foundation::Collections::VectorChangedEventHandler<IInspectable *>,ABI::Windows::Foundation::Collections::IObservableVector<IInspectable *>,ABI::Windows::Foundation::Collections::IVectorChangedEventArgs>::Raise(ABI::Windows::Foundation::Collections::IObservableVector<IInspectable *> * pSource, ABI::Windows::Foundation::Collections::IVectorChangedEventArgs * pArgs) Line 303	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ItemCollection::OnCollectionChanged(ABI::Windows::Foundation::Collections::IObservableVector<IInspectable *> * pSender, ABI::Windows::Foundation::Collections::IVectorChangedEventArgs * e) Line 388	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ItemCollection::RaiseVectorChanged(ABI::Windows::Foundation::Collections::CollectionChange action, unsigned int index) Line 297	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ItemCollection::UpdateItemsSourceList(ABI::Windows::Foundation::Collections::IIterable<IInspectable *> * pValue) Line 356	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ItemsControl::OnItemsSourceChanged(IInspectable * pNewValue) Line 248	C++
 	Microsoft.UI.Xaml.dll!DirectUI::Selector::OnItemsSourceChanged(IInspectable * pNewValue) Line 411	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ItemsControl::OnPropertyChanged2(const PropertyChangedParams & args) Line 122	C++
 	Microsoft.UI.Xaml.dll!DirectUI::Selector::OnPropertyChanged2(const PropertyChangedParams & args) Line 137	C++
 	Microsoft.UI.Xaml.dll!DirectUI::ListViewBase::OnPropertyChanged2(const PropertyChangedParams & args) Line 146	C++
 	Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::NotifyPropertyChanged(const PropertyChangedParams & args) Line 2240	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::NotifyPropertyChanged(CDependencyObject *) Line 2661	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!CFxCallbacks::DependencyObject_NotifyPropertyChanged(CDependencyObject *) Line 606	C++
 	Microsoft.UI.Xaml.dll!CDependencyObject::NotifyPropertyChanged(const PropertyChangedParams & args) Line 2823	C++
 	Microsoft.UI.Xaml.dll!CDependencyObject::SetEffectiveValue(const CDependencyObject::EffectiveValueParams & args) Line 1637	C++
 	Microsoft.UI.Xaml.dll!CDependencyObject::UpdateEffectiveValue(const CDependencyObject::UpdateEffectiveValueParams & args) Line 1903	C++
 	Microsoft.UI.Xaml.dll!CDependencyObject::SetValue(const SetValueParams & args) Line 1669	C++
 	Microsoft.UI.Xaml.dll!CUIElement::SetValue(const SetValueParams & args) Line 727	C++
 	Microsoft.UI.Xaml.dll!CFrameworkElement::SetValue(const SetValueParams & args) Line 235	C++
 	Microsoft.UI.Xaml.dll!CControl::SetValue(const SetValueParams & args) Line 106	C++
 	Microsoft.UI.Xaml.dll!CItemsControl::SetValue(const SetValueParams & args) Line 125	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!DependencyObject_SetValue(CDependencyObject *) Line 2221	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::SetValueCore(const SetValueParams &) Line 1034	C++
 	Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::SetValueCore(const CDependencyProperty * dp, IInspectable * value, bool setEffectiveValueOnly, BaseValueSource baseValueSource) Line 1372	C++
 	[Inline Frame] Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::SetValueCore(const CDependencyProperty *) Line 247	C++
 	Microsoft.UI.Xaml.dll!DirectUI::DependencyObject::SetValueByKnownIndex(KnownPropertyIndex nPropertyIndex, IInspectable * pValue) Line 1107	C++
 	[Managed to Native Transition]	
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IItemsControl.ItemsSource.set(object value) Line 109806	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.ItemsControl.ItemsSource.set(object value) Line 22766	C#
 	Microsoft.Toolkit.Uwp.SampleApp.dll!Microsoft.Toolkit.Uwp.SampleApp.SamplePages.AdaptiveGridViewPage.OnXamlRendered(Microsoft.UI.Xaml.FrameworkElement control) Line 29	C#
 	Microsoft.Toolkit.Uwp.SampleApp.dll!Microsoft.Toolkit.Uwp.SampleApp.SampleController.XamlFrameworkElement_Loaded.AnonymousMethod__0() Line 579	C#
 	Microsoft.Windows.SDK.NET.dll!ABI.Windows.UI.Core.DispatchedHandler.Do_Abi_Invoke.AnonymousMethod__14_0(Windows.UI.Core.DispatchedHandler invoke)	Unknown
 	WinRT.Runtime.dll!WinRT.ComWrappersSupport.MarshalDelegateInvoke<Windows.UI.Core.DispatchedHandler>(System.IntPtr thisPtr, System.Action<Windows.UI.Core.DispatchedHandler> invoke) Line 62	C#
 	Microsoft.Windows.SDK.NET.dll!ABI.Windows.UI.Core.DispatchedHandler.Do_Abi_Invoke(System.IntPtr thisPtr)	Unknown
 	[Native to Managed Transition]	
 	Windows.UI.dll!00007ffb4eb26505()	Unknown
 	CoreMessaging.dll!00007ffb5e484026()	Unknown
 	CoreMessaging.dll!00007ffb5e458ff2()	Unknown
 	CoreMessaging.dll!00007ffb5e458f5b()	Unknown
 	CoreMessaging.dll!00007ffb5e44228f()	Unknown
 	CoreMessaging.dll!00007ffb5e441af2()	Unknown
 	CoreMessaging.dll!00007ffb5e43f44b()	Unknown
 	CoreMessaging.dll!00007ffb5e43e58f()	Unknown
 	CoreMessaging.dll!00007ffb5e43e1d3()	Unknown
 	CoreMessaging.dll!00007ffb5e494836()	Unknown
 	CoreMessaging.dll!00007ffb5e493e53()	Unknown
 	CoreMessaging.dll!00007ffb5e494a46()	Unknown
 	user32.dll!00007ffb662eee9e()	Unknown
 	user32.dll!00007ffb662ee81c()	Unknown
 	user32.dll!00007ffb66303813()	Unknown
 	ntdll.dll!00007ffb66e17b54()	Unknown
 	win32u.dll!ZwUserGetMessage() Line 190	Unknown
 	user32.dll!00007ffb6630401e()	Unknown
 	Microsoft.UI.Xaml.dll!DirectUI::FrameworkApplication::ProcessEvents() Line 1142	C++
 	Microsoft.UI.Xaml.dll!DirectUI::FrameworkApplication::StartDesktop() Line 215	C++
 	Microsoft.UI.Xaml.dll!DirectUI::FrameworkApplicationFactory::Start(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback * pCallback) Line 713	C++
 	[Managed to Native Transition]	
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStatics.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Line 14194	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Line 222	C#
 	Microsoft.Toolkit.Uwp.SampleApp.dll!Microsoft.Toolkit.Uwp.SampleApp.Program.Main(string[] args) Line 26	C#
 	[Native to Managed Transition]	
 	hostpolicy.dll!00007ffb150c297e()	Unknown
 	hostpolicy.dll!00007ffb150c2be7()	Unknown
 	hostpolicy.dll!00007ffb150c35eb()	Unknown
 	hostfxr.dll!00007ffb246375ae()	Unknown
 	hostfxr.dll!00007ffb2463ade4()	Unknown
 	hostfxr.dll!00007ffb2463978f()	Unknown
 	hostfxr.dll!00007ffb24635b19()	Unknown
 	Microsoft.Toolkit.Uwp.SampleApp.exe!00007ff7d7aee183()	Unknown
 	Microsoft.Toolkit.Uwp.SampleApp.exe!00007ff7d7aee578()	Unknown
 	Microsoft.Toolkit.Uwp.SampleApp.exe!00007ff7d7af0148()	Unknown
 	kernel32.dll!00007ffb66239784()	Unknown
 	ntdll.dll!00007ffb66d796a1()	Unknown

@jkoritzinsky
Copy link
Member

Can you figure out where the native side is returning the E_NOINTERFACE HResult from? If we can know which QI is failing, it will make fixing this a lot easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Issue has been fixed in an upcoming or existing release
Projects
None yet
3 participants