gpt4 book ai didi

windows - 终结器中的 WCF NullReferenceException

转载 作者:可可西里 更新时间:2023-11-01 11:33:49 27 4
gpt4 key购买 nike

我们遇到了 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 更新后出现(并在卸载后消失)。

最佳答案

问题原来是IClientChannel

我们忘记在使用后释放 channel ,并从终结器线程调用了 Dispose()

我的猜测是 IClientChannel 使用非托管资源,这些资源必须从创建它们的同一个线程中释放。

从同一个线程调用 Dispose() 后,问题就消失了。

关于windows - 终结器中的 WCF NullReferenceException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16580786/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com