Hi,
I'm not sure where to post this as it's about windows forms, web forms,
socket communication and embedded objects.
I am developing a smart client which is embedded in a webform. This client
software communicates with a third party windows service over sockets.
However I have a weird exception being raised in the AppDomain that I can't
handle. When I finish the socket communication (all asyncronous) I popup a
modal winform, which when closed causes the following exception;
System.InvalidOperationException was unhandled
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)."
Source="mscorlib"
StackTrace:
at System.Threading.SynchronizationContextSwitcher.Un do()
at System.Threading.ExecutionContextSwitcher.Undo()
at System.Threading.ExecutionContext.runFinallyCode(O bject userData,
Boolean exceptionThrown)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteBackoutCodeHelper(Object backoutCode, Object userData, Boolean exceptionThrown)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(Exec utionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
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.Compl etionPortCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at
System.Threading._IOCompletionCallback.PerformIOCo mpletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
The wierd thing is that, if I don't open the message window I don't get the
exception. The message window is just a form with a label and a button, so I
am assuming there is something lower level that is causing the above
exception?!?!
Any help would be appreciated as I have spent two days trying to figure this
one out.
Thanks,
Simon