ArgumentException随机发生

时间:2012-11-27 16:50:16

标签: windows-phone-7 startup argumentexception

有时当我的应用程序尝试启动时,抛出ArgumentException“参数不正确”。不幸的是,异常是随机发生的,所以很难修复它。

InnerException和StackTrace为空:(。

这是输出:

'TaskHost.exe' (Managed): Loaded 'mscorlib.dll'
'TaskHost.exe' (Managed): Loaded 'System.Windows.RuntimeHost.dll'
'TaskHost.exe' (Managed): Loaded 'System.dll'
'TaskHost.exe' (Managed): Loaded 'System.Windows.dll'
'TaskHost.exe' (Managed): Loaded 'System.Net.dll'
'TaskHost.exe' (Managed): Loaded 'System.Core.dll'
'TaskHost.exe' (Managed): Loaded 'System.Xml.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\SmartLib.dll', Symbols loaded.
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\RestSharp.WindowsPhone.dll'
'TaskHost.exe' (Managed): Loaded 'Microsoft.Phone.dll'
'TaskHost.exe' (Managed): Loaded 'Microsoft.Phone.Interop.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\JeffWilcox.PhoneThemeManager.dll'
'TaskHost.exe' (Managed): Loaded 'System.Xml.Linq.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\System.Windows.Interactivity.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\Microsoft.Expression.Interactions.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\Microsoft.Phone.Controls.Toolkit.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\System.Threading.Tasks.dll'
A first chance exception of type 'System.MethodAccessException' occurred in mscorlib.dll
'TaskHost.exe' (Managed): Loaded 'System.Runtime.Serialization.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\WPExtensions.dll', Symbols loaded.
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\Microsoft.Phone.Controls.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\Silverlight_ZXing_Core.dll'
'TaskHost.exe' (Managed): Loaded '\Applications\Install\35353739-1684-48DB-A5D2-F849FC676154\Install\Microsoft.Threading.Tasks.dll'
A first chance exception of type 'System.MethodAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
'TaskHost.exe' (Managed): Loaded 'System.SR.dll'

有时一切正常,但有时我连续10次无法运行应用程序。

编辑1: 调用堆栈:

  

SmartLib.dll!SmartLib.App.Application_UnhandledException(object sender = {SmartLib.App},System.Windows.ApplicationUnhandledExceptionEventArgs e = {System.Windows.ApplicationUnhandledExceptionEventArgs})第348行+ 0x5字节C#       System.Windows.dll!MS.Internal.Error.CallApplicationUEHandler(System.Exception e = {“参数不正确。”})+ 0x30字节
      System.Windows.dll!MS.Internal.Error.CallAUEHandler(uint hr = 2147942487,out uint bIsHandled = 0)+ 0x6 bytes
      [原生于管理过渡]

编辑2: 堆栈跟踪:

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)
   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 System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   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.PhoneApplicationFrame.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

编辑3:

根据Stack Trace,它似乎是由第一页可视化中的一些错误引起的。但根据我的分析:)它似乎是由从服务器获取错误的错误引起的。

APP信息:

我的应用程序提供有关图书馆图书的信息。有时当应用程序启动并尝试更新图书评级时,应用程序将崩溃。应用程序在获得响应之前崩溃。 我使用RestSharp Library发送HTTP请求。

1 个答案:

答案 0 :(得分:0)

确定。似乎问题与此问题相同:

UnhandledException in WP7

如果您遇到同样的问题,请在此投票: http://connect.microsoft.com/VisualStudio/feedback/details/731082/windows-phone-forum-when-adding-multi-usercontrol-with-x-name-attribute-to-visualtree-exception-the-parameter-is-incorrect-is-thrown

非常感谢KooKiz向我展示如何查看异常的堆栈跟踪:)。它帮助我找到问题的解决方案。