在做WP8開發的過程中,使用到了longlistselector這個控件,本來使用沒有問題。
但是突然出現了一個閃退的錯誤,錯誤信息如下:
{MS.Internal.WrappedException: Error HRESULT E_FAIL has been returned from a call to a COM component. ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
at Microsoft.Phone.Controls.LongListSelector.Balance()
at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
--- End of inner exception stack trace ---}
看似很復雜,搞得我也不知道從何下手。
回想整個開發過程,之前使用正常,后面閃退,期間做了全局資源命名的調整,但是vs沒有給出錯誤提示,本以為替換完畢(其實應該全局查找替換的)。
但遺漏了一個地方,longlistselector中的HeaderDataTemplate中的一個資源使用的地方。
在做了更改后,使用又恢復正常了。