WP7中的UnhandledException

kgr*_*gen 11 c# unhandled-exception windows-phone-7 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)
Run Code Online (Sandbox Code Playgroud)

Jan*_* K. 6

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