문제

We had problems with WCF that took us a long time to diagnose so I'm posting them here in case someone has similar issues (haven't found a reference anywhere else).

Our processes would often crash with the following unhandled exceptions:

System.NullReferenceException: Object reference not set to an instance of an object.
 at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
 at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
 at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

System.NullReferenceException: Object reference not set to an instance of an object.
 at System.Threading.Overlapped.Free(NativeOverlapped* nativeOverlappedPtr)
 at System.ServiceModel.Channels.OverlappedContext.Free()
 at System.ServiceModel.Channels.OverlappedContext.FreeOrDefer()
 at System.ServiceModel.Channels.SocketConnection.Abort(TraceEventType traceEventType, String timeoutErrorString, TransferOperation transferOperation)
 at System.ServiceModel.Channels.CommunicationPool`2.EndpointConnectionPool.CloseIdleConnection(TItem connection, TimeSpan timeout)
 at System.ServiceModel.Channels.IdlingCommunicationPool`2.IdleTimeoutEndpointConnectionPool.IdleTimeoutIdleConnectionPool.OnIdle()
 at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
 at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
 at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

System.NullReferenceException: Object reference not set to an instance of an object.
 at System.Threading.Overlapped.Free(NativeOverlapped* nativeOverlappedPtr)
 at System.Net.AsyncRequestContext.Dispose(Boolean disposing)
 at System.Net.RequestContextBase.Finalize()

Exceptions usually occured several hours after staring the process, sometimes after a few minutes.

Strangely they would only show up after installing the Jan. 2013 Windows Updates (and go away after uninstalling them).

도움이 되었습니까?

해결책

The problem turned out to be IClientChannel.

We forgot to dispose the channel after use and called Dispose() from the finalizer thread.

My guess is that IClientChannel uses unmanaged resources that have to be released from the same thread that created them.

After calling Dispose() from the same thread the issue went away.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top