【问题标题】:Access Violation Exception when using outlook address book使用 Outlook 通讯簿时出现访问冲突异常
【发布时间】:2013-10-01 14:13:52
【问题描述】:

环境 Win XP , Outlook 2003

  1. 我有一个 WPF 组件,它使用 Interop.MAPI 打开 Outlook 通讯录

  2. 用户将选择多个收件人并选择确定,然后关闭通讯录。

  3. 关闭弹出窗口后,我会注意到等待光标出现,几秒钟后我收到错误消息,然后我的应用程序 (WPF) 被终止。

我花了好几个小时才弄清楚还是没有运气,我从事件查看器中复制了以下异常。

  • 我发现通讯录模块没有问题 因为相同的地址簿在不同的模块中使用 很好。

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

异常信息:System.AccessViolationException 堆: 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG 参考) 在 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.ReportHeaderViewModel.ShowDistributionList() 在 xxxxx.Frw.Region.Reu.Client.UI.ViewModels.ReportHeaderViewModel.b__1(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.InvokeEventHandler(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.InvokeEventHandler(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.ProcessStagingArea() 在 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,布尔 ByRef) 在 MS.Win32.HwndWrapper.WndProc(IntPtr,Int32,IntPtr,IntPtr,布尔 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.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG 参考) 在 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()

【问题讨论】:

    标签: c# wpf access-violation mapi outlook-2003


    【解决方案1】:

    虽然我不知道是什么导致了这个问题,但我还是找到了防止应用程序崩溃的解决方案,

    由于未处理的异常将最后调用的托管代码方法显示为

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

    在添加此属性后,我只是添加了一个带有HandleProcessCorruptedStateExceptions 方法修饰的try catch,我能够捕获由未映射的MAPI 互操作引发的异常并处理应用程序崩溃问题。

    [HandleProcessCorruptedStateExceptions]
    public void ShowDialog()
    {
     try
      {
      }
     Catch(Exception ex)
      {
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-12
      相关资源
      最近更新 更多