none
Exceção no SaveFileDialog RRS feed

  • Pergunta

  • A dúvida é o seguinte: 

    Numa aplicação bem básica do SaveFileDialog o programa gera a seguinte exceção:

    "Tentativa de leitura ou gravação em memória protegida. Normalmente, isso é uma indicação de que outra memória está danificada".

    O que me parece muito estranho é que a exceção é "unhandled" mesmo com bloco try/catch, e quando o binário é executado o software trava mesmo com bloco try/catch.

    Segue o pedaço do código:

     Try
                Dim DialogoSalvarArquivo As New SaveFileDialog()

                Dim NomeArquivo As String = "Relatório Geral de Chamadas"

                DialogoSalvarArquivo.Filter = "Arquivo PDF|"
                DialogoSalvarArquivo.FileName = NomeArquivo

                If DialogoSalvarArquivo.ShowDialog() <> Windows.Forms.DialogResult.OK Then
                    MsgBox("Emissão de Relatório Cancelada")
                    Return
                End If

            Catch ex As Exception
                UtilMsgBox.ExibaMsgAdvertencia(ex.ToString())
            End Try

    Alguém por favor poderia me dar uma ajuda <3

    Desde já grato!

    -----------------------------------

    Detalhes da Exceção:

    System.AccessViolationException was unhandled
      HResult=-2147467261
      Message=Tentativa de leitura ou gravação em memória protegida. Normalmente, isso é uma indicação de que outra memória está danificada.
      Source=System.Windows.Forms
      StackTrace:
           em System.Windows.Forms.FileDialogNative.IFileDialog.Show(IntPtr parent)
           em System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner)
           em System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
           em Pctel_Supervisor_Desktop.ControladorDeTelaDeRelatorios.ExportaRelatorioGeral(Int32 Formato) na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\ControladoresDeTela\ControladorDeTelaDeRelatorios.vb:linha 138
           em Pctel_Supervisor_Desktop.Window2.btoExportarCSV_Click(Object sender, RoutedEventArgs e) na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\Formularios\GeraRelatorios.xaml.vb:linha 76
           em System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           em System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           em System.Windows.Controls.Button.OnClick()
           em System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
           em System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           em System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           em System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
           em System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           em System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           em System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           em System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
           em System.Windows.Input.InputManager.ProcessStagingArea()
           em System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
           em System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
           em System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           em System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           em MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           em MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           em System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           em MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           em System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           em System.Windows.Window.ShowHelper(Object booleanBox)
           em System.Windows.Window.ShowDialog()
           em Pctel_Supervisor_Desktop.UtilAbreTela.AbraTelaRelatorios() na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\Utilidades\UtilAbreTela.vb:linha 210
           em Pctel_Supervisor_Desktop.Principal.AbraJaneRelatorios() na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\Formularios\Principal.xaml.vb:linha 370
           em Pctel_Supervisor_Desktop.Principal._Lambda$__8(Object a0, RoutedEventArgs a1) na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\obj\x86\Debug\Formularios\Principal.g.vb:linha 294
           em System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           em System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           em System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
           em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           em System.Windows.Threading.DispatcherOperation.InvokeImpl()
           em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           em System.Windows.Threading.DispatcherOperation.Invoke()
           em System.Windows.Threading.Dispatcher.ProcessQueue()
           em System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           em MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           em MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           em System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           em MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           em System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           em System.Windows.Application.RunInternal(Window window)
           em System.Windows.Application.Run()
           em Pctel_Supervisor_Desktop.Application.Main() na D:\PCTEL_DEV\Software\Pctel_Supervisor_Desktop_Protocolo\Codigo\Pctel_Supervisor_Desktop\Pctel_Supervisor_Desktop\obj\x86\Debug\Application.g.vb:linha 66
           em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           em System.Threading.ThreadHelper.ThreadStart()
      InnerException: 

    segunda-feira, 17 de outubro de 2016 13:21

Respostas

Todas as Respostas