Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnhandledException in WP7

I am getting this weird error when making a WP7 app, and I can not see why. The only output/ error message I get is "UnhandledException: The parameter is incorrect. : : : 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)
like image 499
kgrevehagen Avatar asked Sep 14 '11 08:09

kgrevehagen


1 Answers

I had the same problem. The fix for me was to give every element I would like to add a unique name (e.g. Name = Guid.NewGuid().ToString()). I hope this helps for you, too!

like image 74
Jan K. Avatar answered Oct 15 '22 14:10

Jan K.