1

WCF に問題があり、診断に長い時間がかかったので、誰かが同様の問題を抱えている場合に備えてここに投稿しています (他に参照が見つかりませんでした)。

私たちのプロセスは、次の未処理の例外でクラッシュすることがよくありました。

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()

例外は通常、プロセスを開始してから数時間後に発生し、数分後に発生することもありました。

奇妙なことに、それらは 2013 年 1 月の Windows Update をインストールした後にのみ表示されます (そして、それらをアンインストールすると消えます)。

4

1 に答える 1

3

問題は次のとおりであることが判明しましたIClientChannel

使用後にチャネルを破棄するのを忘れてDispose()、ファイナライザ スレッドから呼び出しました。

私の推測では、IClientChannel はアンマネージ リソースを使用しており、それらを作成したのと同じスレッドから解放する必要があります。

Dispose()同じスレッドから呼び出した後、問題は解消されました。

于 2013-05-16T06:50:56.587 に答える