c# - WP7 中的未处理异常

标签 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)

最佳答案

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

关于c# - WP7 中的未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7413293/

相关文章:

c# - 需要帮助在 C# 中编写嵌套 SQL 查询

silverlight - 是否可以在 Windows Phone 7 模拟器上安装不同的字体?

exception - 系统.IO.FileLoadException。无法加载辅助功能,版本 = 2.0.0.0

c# - Visual Studio 2015 中断未处理的异常不起作用

c# - 对 Ands : System. Guid 进行级联相等性检查

c# - 我在 Unity 中使用了 C# 秒表类,但它只返回 00 :00:00

windows-phone-7 - Windows Phone 为图像添加边框

c++ - 在 MS Visual C++ 中调试未处理异常的正确方法

c# - 如何使用从单独项目创建的 Windows 服务

javascript - Windows Phone WebBrowser - onClick javascript 不起作用