我在制作 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)
最佳答案
我遇到了同样的问题。对我来说,解决方法是为每个我想添加唯一名称的元素(例如 Name = Guid.NewGuid().ToString())。我希望这对你也有帮助!
关于c# - WP7 中的未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7413293/