【发布时间】:2010-12-18 23:57:43
【问题描述】:
我正在为一个在迁移到 .NET 的过程中拥有 VB6 应用程序的客户工作。
目前他们有一个 .NET shell,但在 .NET 中托管了一些旧的 VB6 控件。 我偶然发现的一个错误是当它们在 .NET 中异步从数据库中提取一些数据,然后将该数据转发到 COM 组件以显示它时发生的日志:
The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).
Err Source: mscorlib
Err Type: System.InvalidOperationException
ERROR stack trace:
at System.Threading.SynchronizationContextSwitcher.Undo()
at System.Threading.ExecutionContextSwitcher.Undo()
at System.Threading.ExecutionContext.runFinallyCode(Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteBackoutCodeHelper(Object backoutCode, Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
然后在日志中显示以下内容:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Err Source: mscorlib
Err Type: System.AccessViolationException
ERROR stack trace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at _Client's component that forwards calls to COM_
有没有人遇到过这样的事情?我该如何解决?
【问题讨论】: