Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用outlook通讯簿时发生访问冲突异常_C#_Wpf_Access Violation_Mapi_Outlook 2003 - Fatal编程技术网

C# 使用outlook通讯簿时发生访问冲突异常

C# 使用outlook通讯簿时发生访问冲突异常,c#,wpf,access-violation,mapi,outlook-2003,C#,Wpf,Access Violation,Mapi,Outlook 2003,环境Win XP,Outlook 2003 我有一个WPF组件,它使用Interop.MAPI 用户将选择多个收件人并选择ok,然后关闭通讯簿 一旦弹出窗口关闭,我可以注意到等待光标出现,几秒钟后我收到错误消息,然后我的应用程序(WPF)终止 我花了几个小时才弄明白,还是没有运气,我从事件查看器复制了以下异常 我发现通讯录模块没有问题 因为同一个地址簿在它工作的不同模块中使用 好的 在我打开通讯录并读取所选姓名的方法中,从未到达Catch块 异常信息:System.AccessViolati

环境Win XP,Outlook 2003

  • 我有一个WPF组件,它使用
    Interop.MAPI

  • 用户将选择多个收件人并选择ok,然后关闭通讯簿

  • 一旦弹出窗口关闭,我可以注意到等待光标出现,几秒钟后我收到错误消息,然后我的应用程序(WPF)终止

  • 我花了几个小时才弄明白,还是没有运气,我从事件查看器复制了以下异常

    • 我发现通讯录模块没有问题 因为同一个地址簿在它工作的不同模块中使用 好的

    • 在我打开通讯录并读取所选姓名的方法中,从未到达Catch块

    异常信息:System.AccessViolationException 堆栈: 位于MS.Win32.unsafentivemethods.DispatchMessage(System.Windows.Interop.MSG ByRef) 位于System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 位于System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 位于System.Windows.Window.ShowHelper(System.Object) 在System.Windows.Window.Show()中 在System.Windows.Window.ShowDialog()中 位于xxxxx.Frw.Base.Client.UI.DialogService.ShowDialog(xxxxx.Frw.Base.Client.UI.BaseViewModel) 在xxxxx.Frw.Base.Client.UI.DialogService.ShowDialog(xxxxx.Frw.Base.Client.UI.BaseViewModel, System.Windows.Controls.UserControl) 在xxxxx.Frw.Region.Reu.Client.UI.ViewModels.ReportHeadServiceWModel.ShowDistributionList()中 位于xxxxx.Frw.Region.Reu.Client.UI.ViewModels.ReportHeadServiceModel.b_uu1(System.Object) 位于xxxxx.Frw.Base.Client.UI.Commands.RelayCommand.Execute(System.Object) 在MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, 布尔值) 在System.Windows.Controls.Primitives.ButtonBase.OnClick()中 在System.Windows.Controls.Button.OnClick()中 位于System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs) 在System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs) 在System.Windows.Input.MouseButtonEventArgs.InvokeeEventHandler(System.Delegate, 系统(对象) 在System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, 系统(对象) 在System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs) 在System.Windows.EventRoute.InvokeHandlersImpl(System.Object,System.Windows.RoutedEventArgs,布尔值) 在System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs,System.Windows.RoutedEvent) 位于System.Windows.UIElement.OnMouseUpThunk(System.Object、System.Windows.Input.MouseButtonEventArgs) 在System.Windows.Input.MouseButtonEventArgs.InvokeeEventHandler(System.Delegate, 系统(对象) 在System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, 系统(对象) 在System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs) 在System.Windows.EventRoute.InvokeHandlersImpl(System.Object,System.Windows.RoutedEventArgs,布尔值) 在System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs) 位于System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs) 在System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, 布尔值) 在System.Windows.Input.InputManager.ProcessStaginArea()中 位于System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs) 位于System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport) 在System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode,Int32, System.Windows.Input.RawMouseActions,Int32,Int32,Int32) 在System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage、IntPtr、IntPtr、Boolean ByRef) 在System.Windows.Interop.HwndSource.InputFilterMessage中(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef) 位于MS.Win32.hwndwapper.WndProc(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef) 位于MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) 在System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,Int32) 在MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate,System.Object,Int32,System.Delegate) 在System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority)中, System.TimeSpan、System.Delegate、System.Object、Int32) 在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,IntPtr,IntPtr) 位于MS.Win32.unsafentivemethods.DispatchMessage(System.Windows.Interop.MSG ByRef) 位于System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 位于System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 位于System.Windows.Application.RunDispatcher(System.Object) 位于System.Windows.Application.RunInternal(System.Windows.Window) 在System.Windows.Application.Run(System.Windows.Window)中 在xxxxx.Frw.Main.Client.UI.App.Main()上


    尽管我无法找出导致此问题的原因,但我找到了防止应用程序崩溃的解决方案

    因为未处理的异常将上次调用的托管代码方法显示为

    xxxxx.Frw.Base.Client.UI.DialogService.ShowDialog()

    我只是简单地添加了一个[HandleProcessCorruptedStateExceptions] public void ShowDialog() { try { } Catch(Exception ex) { } }