Tengo un programa en C# (objetivo NET Framework 4.0) que hace que las llamadas a los objetos COM (código no administrado), todos los objetos administrados adecuadamente y se desgarra cuando ya no sean necesarios, etc.C "Intento de leer o escribir en la memoria protegida" o "componente externo ha iniciado una excepción"
también tengo manejador pocas excepciones, bloques try/catch sin excepciones personalizadas. Sin embargo, algunas veces este programa se bloquea, funciona la mayoría de las veces, el comportamiento aleatorio. trazas de la pila también varían, ejemplo:
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:
En Program.cs, Línea 17: Application.Run (nuevo 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:
Estoy en la etapa de aislamiento para averiguar la raíz de este error.
- ¿Tiene alguna sugerencia de este error?
- Cualquier sugerencia sobre atrapar estas excepciones y salir con gracia.
Gracias por su ayuda.
Deberá depurar el código nativo. Eso requiere un depurador no administrado. –
¿Transfiere referencias sobre los objetos .NET a los componentes COM? – Seb