質問

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