WP7 中的未处理异常 [英] UnhandledException in WP7

查看:17
本文介绍了WP7 中的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在制作 WP7 应用程序时遇到这个奇怪的错误,我不明白为什么.我得到的唯一输出/错误消息是UnhandledException:参数不正确.:::ProgramName.App"

I am getting this weird error when making a WP7 app, and I can not see why. The only output/ error message I get is "UnhandledException: The parameter is incorrect. : : : ProgramName.App"

这个错误是随机发生的,我没有从调试器那里得到任何关于如何解决它的信息.当我运行相同的代码两次时,一次出现错误,另一次则没有.那么,你们中有没有人以前遇到过这个错误,也许可以告诉我为什么会这样?这太令人沮丧了,因为它发生得如此随机.任何建议将不胜感激:)

This error occurs randomly, and I do not get any information from the debugger on how to resolve it. When I run the same code twice, one time it gets the error, and the other time it does not. So, have any of you got this error before, and can maybe tell me why it is happening? This is so frustrating, because it happens so randomly. Any proposals will be highly appreciated :)

这是完整的堆栈跟踪:

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
at System.Windows.PresentationFrameworkCollection`1.Add(UIElement value)
at System.Windows.Controls.ItemsControl.AddVisualChild(Int32 index, DependencyObject container, Boolean needPrepareContainer)
at System.Windows.Controls.ItemsControl.AddContainers()
at System.Windows.Controls.ItemsControl.RecreateVisualChildren(IntPtr unmanagedObj)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.Pivot.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

推荐答案

我遇到了同样的问题.对我来说,解决方法是为我想要添加的每个元素添加一个唯一名称(例如 Name = Guid.NewGuid().ToString()).我希望这对您也有帮助!

I had the same problem. The fix for me was to give every element I would like to add a unique name (e.g. Name = Guid.NewGuid().ToString()). I hope this helps for you, too!

这篇关于WP7 中的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆