简体   繁体   English

WP7中的UnhandledException

[英]UnhandledException in WP7

I am getting this weird error when making a WP7 app, and I can not see why. 在制作WP7应用程序时,我遇到了这个奇怪的错误,我看不出原因。 The only output/ error message I get is "UnhandledException: The parameter is incorrect. : : : ProgramName.App" 我得到的唯一输出/错误消息是“UnhandledException:参数不正确。::: 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 :) 任何提案都将受到高度赞赏:)

EDIT: Here is the full stack trace: 编辑:这是完整的堆栈跟踪:

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)

I had the same problem. 我有同样的问题。 The fix for me was to give every element I would like to add a unique name (eg Name = Guid.NewGuid().ToString()). 对我来说,修复是给每个我想要添加唯一名称的元素(例如Name = Guid.NewGuid()。ToString())。 I hope this helps for you, too! 我希望这对你也有帮助!

Click on Debug then Exceptions and then set Common Language Runtime Exceptions to "Thrown" and you should see the stack trace. 单击Debug然后单击Exceptions,然后将Common Language Runtime Exceptions设置为“Thrown”,您应该看到堆栈跟踪。

However, I do think it is a bug and can't tell how to go around it without looking at code/stacktrace 但是,我确实认为这是一个错误,并且不知道如何在不查看代码/堆栈跟踪的情况下绕过它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM