System.InvalidCastException: 'Unable to cast object of type 'ApplicationView' to type 'IApplicationView9

倖福魔咒の 提交于 2020-08-10 19:21:36

问题


var displayRegion= ApplicationView.GetForCurrentView().GetDisplayRegions() In some devices, I am getting this exception, System.InvalidCastException: 'Unable to cast object of type 'Windows.UI.ViewManagement.ApplicationView' to type 'Windows.UI.ViewManagement.IApplicationView9'. How to avoid this exception?


回答1:


The GetDisplayRegions API was introduced in Windows 10, version 1903 (introduced in 10.0.18362.0) (see Docs). This means you have to first check if the API is present on the current device using APIInformation.IsMethodPresent.



来源:https://stackoverflow.com/questions/62556132/system-invalidcastexception-unable-to-cast-object-of-type-applicationview-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!