2010-05-14 3 views
5

ho ottenuto la seguente eccezione:InvalidOperationException: l'operazione di annullamento ha rilevato un contesto diverso da quello che è stato applicato nel funzionamento Set corrispondente

Exception Type: System.InvalidOperationException 
Exception Message: 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). 
Exception Stack: 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.Net.ContextAwareResult.Complete(IntPtr userToken) 
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) 
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) 
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 
Exception Source: mscorlib 
Exception TargetSite.Name: Undo 
Exception HelpLink: 

L'applicazione è un Visual Studio 2005 (Net 2.0) applicazione console . È un server per più connessioni TCP/IP, esegue letture asincrone dei socket e scritture socket sincrone.

Nella ricerca di una risposta mi sono imbattuto in this post che parla di una chiamata a Application.Doevents() che non uso nel mio codice.

Ho trovato anche this post che ha una risoluzione coinvolta con Component che anch'io non uso nel mio codice. L'applicazione fa riferimento a una libreria che ho creato che contiene controlli e componenti utente personalizzati, ma non vengono utilizzati dall'applicazione.

Domanda: Che cosa ha causato ciò e come posso evitare che ciò accada di nuovo? Oppure una domanda più realistica: cosa significa in realtà questa eccezione? Come viene definito "contesto" in questa situazione?

Tutto ciò che può aiutarmi a capire cosa sta succedendo sarebbe molto apprezzato.

risposta

0

contesto si riferisce a come "Thread Context" e non è in alcun modo correlato al codice. Tuttavia si tratta di un problema interno con .net che potrebbe essere limitato alle edizioni beta

Problemi correlati