有时,当我的应用程序尝试启动时,会引发 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 bytes
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 的说法,这似乎是由可视化首页的一些错误引起的。但根据我的分析:) 这似乎是由于从服务器获取错误导致的错误。
应用信息:
我的应用程序提供有关图书馆书籍的信息。有时,当应用程序启动并尝试更新图书评分时,应用程序会崩溃。应用程序在得到响应之前崩溃。我使用 RestSharp 库发送 HTTP 请求。