2009-08-12 1 views
4

フレームワークで管理されているスレッド(つまりスレッドではありません)で例外が発生したASP.NETアプリケーションをデバッグしようとすると、4時間(イギリスでは3am)しかかかりません。静的メソッドChannelFactory.CreateChannelの結果をIClientChannelにキャストし、明示的にDisposedすることができたことがわかりました。私はそれがすべてうまくいいですが、理由は:IClientChannel反パターン

1)ChannelFactory.CreateChannelはoutパラメータとしてIClientChannelを返しませんか?

2).NetのCreateChannelに関するドキュメントには記載されていませんか?

3).NETドキュメントでは、例(コードは不要)で適切な使用パターンが示されていませんか?

私を間違えないでください - 私は.Netフレームワークが大好きです。 Microsoft(およびKrzysztof Cwalina:Designing Framework Guidelinesを参照)は本当に素晴らしい仕事をしています。だから私はそのような災害を期待していませんでした。 IMyService変数もIClientChannelをサポートしていることを知っておくべきであり、私は明示的にそれを処理すべきですか?

興味のある人は、ここにASP.NETログがあります。

Event Type: Error 
Event Source: ASP.NET 2.0.50727.0 
Event Category: None 
Event ID: 1334 
Date:  12/08/2009 
Time:  01:55:47 
User:  N/A 
Computer: WLGH3GIS 
Description: 
An unhandled exception occurred and the process was terminated. 

Application ID: /LM/W3SVC/1/Root/Maps 

Process ID: 3044 

Exception: System.NullReferenceException 

Message: Object reference not set to an instance of an object. 

StackTrace: at System.Threading.Overlapped.Free(NativeOverlapped* nativeOverlappedPtr) 
    at System.ServiceModel.Channels.OverlappedContext.Free() 
    at System.ServiceModel.Channels.PipeConnection.CloseHandle(Boolean abort, String timeoutErrorString, TransferOperation transferOperation) 
    at System.ServiceModel.Channels.PipeConnection.Close(TimeSpan timeout) 
    at System.ServiceModel.Channels.BufferedConnection.Close(TimeSpan timeout) 
    at System.ServiceModel.Channels.ConnectionPool.CloseItem(IConnection item, TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationPool`2.EndpointConnectionPool.CloseItem(TItem item, TimeSpan timeout) 
    at System.ServiceModel.Channels.IdlingCommunicationPool`2.IdleTimeoutEndpointConnectionPool.CloseItem(TItem item, TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationPool`2.EndpointConnectionPool.CloseIdleConnection(TItem connection, TimeSpan timeout) 
    at System.ServiceModel.Channels.IdlingCommunicationPool`2.IdleTimeoutEndpointConnectionPool.IdleTimeoutIdleConnectionPool.OnIdle() 
    at System.ServiceModel.Channels.IdlingCommunicationPool`2.IdleTimeoutEndpointConnectionPool.IdleTimeoutIdleConnectionPool.OnIdle(Object state) 
    at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2() 
    at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state) 
    at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke() 
    at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks() 
    at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state) 
    at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) 
    at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) 
    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 
+0

カロル、あなたはFAQを読んで、これを質問として言い返すべきです(そして答えを投稿するかもしれません)。 –

答えて

4

カロルは、私は、これは少し古いですけど、私はあなたに感謝したいです。あなたの記事は本当に私を助けました。

私が抱いていた症状は、サーバーでChannelFactoryを閉じるときに、OpenTimeout、ReceiveTimeout、SendTimeout、InactivityTimeout、またはCloseTimeoutに設定された時間幅の長さに関係なく、常にタイムアウトを与えるということでした。

解決策は、実際にはクライアント上で、ChannelFactory.CreateChannelから返されたIMyServiceInterfaceをICommunicationObjectにキャストすることでした。その後、Util.SafeCloseAndDispose(ICommunicationObject)メソッドにうまく渡して、Web上にコピーして貼り付けることができます。

私はクライアントでこれを実行した後、サーバーのChannelFactoryをわずか2〜2秒で閉じることができます。これ以上のタイムアウトはありません。

私の知る限りでは、この問題を綴っている唯一の場所は、カロルのポストのこの洞察です。

もう一度、Karol! :)

+0

あなたは大歓迎です。私は自分の発見を公表することが常に良いと思う。いつ他の誰かがそれをGoogleに知らせることは決してありません。 –

関連する問題