数据绑定0x8000ffff上的wp7奇怪的UnhandledException

时间:2011-02-17 11:53:14

标签: data-binding windows-phone-7

我在数据绑定期间遇到一个奇怪的未处理异常。我将ListBox与IList数据绑定。在使用对象填充列表后,我将ListBox的DataContext设置为我的对象:

IList<Users> users = new List<Users>;
foreach(JToken jresult in Users)
{
User juser = JsonConvert.DeserializeObject<User>(jresult.ToString());
users.Add(juser);

this.DataContext = myObject;

我的对象只有两个字段,名称和电子邮件:

public class User
{
    public string name { get; set; }
    public string email { get; set; }    }

在XAML方面,我绑定ListItem和ItemTemplate中的文本块,如下所示:

<ListBox Name="Users" ItemsSource="{Binding}">
<TextBlock Text="{Binding Name}" Name="name" />
<TextBlock Text="{Binding Email}" Name="email" />

在调试期间,我可以看到“用户”列表框中填充了正确的项目,但是在退出该方法后,应用程序崩溃,我直接进入App.xaml.cs方法Application_UnhandledException。错误详情如下:

e.ExceptionObject.InnerException
{"0x8000ffff"}
    _data: null
    _HResult: -2146233088
    _innerException: null
    _message: "0x8000ffff"
    _methodDescs: {System.IntPtr[14]}
    _optionalData: null
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233088
    InnerException: Could not evaluate expression
    Message: "0x8000ffff"
    StackTrace: "   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)\r\n   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)\r\n   at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)\r\n   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)\r\n   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)\r\n   at MS.Internal.XcpImpor
ts.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)\r\n   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)\r\n"

我无法弄清楚这一点,并且非常感谢任何指导,或者对这类问题采取更好的方法。有一篇文章确实提到SilverLight不再支持ListDictionaryInternal,所以我不确定这是否可能是问题,因为错误详细信息指向ListDictionaryInternal。

2 个答案:

答案 0 :(得分:3)

想要听到奇怪的声音。我有这个问题,并在XAML中删除了一个style =“{StaticResource ....}并修复了它。有人可以解释原因吗?我之后添加了一个本地StaticResource,它也有效。

如果您的ListBox项目中没有任何样式设置,那么此解决方案将无济于事。

答案 1 :(得分:0)

它不是关于数据绑定我认为这是一般错误当我正在处理我的项目时我的计算机给我蓝屏错误当我再次启动计算机时我想运行我的项目我看到0x8000FFFF错误我无法找到确切的解决方案网但我试图从visual studio删除licenses.licx文件我解决了问题:)