WP7中的UnhandledException

时间:2011-09-14 08:21:30

标签: c# windows-phone-7 unhandled-exception windows-phone-7.1

制作WP7应用程序时遇到这个奇怪的错误,我看不出原因。我得到的唯一输出/错误消息是“UnhandledException:参数不正确。::: ProgramName.App”

此错误随机发生,我没有从调试器获得有关如何解决它的任何信息。当我运行相同的代码两次,一次得到错误,另一次没有。所以,你们之前是否有过这个错误,也许可以告诉我它为什么会发生?这太令人沮丧了,因为它是随机发生的。任何提案都将受到高度赞赏:)

编辑:这是完整的堆栈跟踪:

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)

2 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分:3)

单击Debug然后单击Exceptions,然后将Common Language Runtime Exceptions设置为“Thrown”,您应该看到堆栈跟踪。

但是,我确实认为这是一个错误,无法告诉如何在不查看代码/堆栈跟踪的情况下解决它

相关问题