Ho un programma C# (framework di destinazione .NET 4.0) che effettua chiamate a oggetti COM (codice non gestito), tutti gli oggetti gestiti correttamente , distrutto quando non più necessario, ecc.Errore C# "Tentativo di leggere o scrivere memoria protetta" o "Componente esterno ha generato un'eccezione"
Ho anche poche eccezioni di gestione, prova/cattura blocchi senza eccezioni personalizzate. Tuttavia alcune volte questo programma si è arrestato in modo anomalo, funziona il più delle volte, il comportamento casuale. stack anche variare, ad esempio:
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at IndexerTester.Program.Main() in D:\Tester\Program.cs:line 17
InnerException:
Nel Program.cs, Linea 17: Application.Run (new Form1());
System.Runtime.InteropServices.SEHException was unhandled
Message=External component has thrown an exception.
Source=System.Windows.Forms
ErrorCode=-2147467259
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at IndexerTester.Program.Main() in D:\Tester\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Sono in fase di isolamento per scoprire la radice di questo errore.
- Avete suggerimenti di questo errore?
- Qualsiasi suggerimento su intercettare queste eccezioni ed uscire con garbo.
Grazie per il vostro aiuto.
È necessario eseguire il debug del codice nativo. Ciò richiede un debugger non gestito. –
Passa i riferimenti sugli oggetti .NET ai componenti COM? – Seb