2009-08-12 2 views
4

프레임 워크가 관리하는 스레드 (예 : 내 스레드가 아님)에서 예외가 발생한 ASP.NET 응용 프로그램을 디버깅하는 데 4 시간 (영국에서 오전 3시)이 걸렸습니다. 방금 정적 메서드 ChannelFactory.CreateChannel의 결과를 IClientChannel에 캐스팅하고 명시 적으로 Disposed라는 사실을 알았습니다. 제 말은 괜찮습니다. 그러나 이유는 무엇입니까?IClientChannel 반 패턴

1) ChannelFactory.CreateChannel은 out 매개 변수로 IClientChannel을 반환하지 않습니까?

2) CreateChannel 용 .Net 설명서에 언급되지 않았습니까?

3) .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

Karol, FAQ를 읽은 다음 질문으로 다시 말하십시오 (그리고 아마도 답변도 게시하십시오). –

답변

4

카롤, 나는 이것이 조금 오래되었음을 알고 있지만 감사 드리고 싶습니다. 귀하의 게시물 정말 날 도와 줬어.

내가 가진 증상은 서버에서 ChannelFactory를 닫으려고 할 때 OpenTimeout, ReceiveTimeout, SendTimeout, InactivityTimeout 또는 CloseTimeout에 설정 한 시간 범위의 길이에 관계없이 항상 Timeout을 제공한다는 것입니다.

실제로 솔루션은 ChannelFactory.CreateChannel에 의해 반환 된 IMyServiceInterface를 ICommunicationObject로 캐스팅합니다. 그런 다음 Util.SafeCloseAndDispose (ICommunicationObject) 메서드를 잘 전달하여 웹 전체에 복사하여 붙여 넣을 수 있습니다.

클라이언트에서 처리 한 후 서버의 ChannelFactory는 더 이상 시간 제한없이 1-2 초 만에 닫을 수 있습니다.

내가 아는 한, 카롤의 게시물에서 얻은이 통찰력은이 문제가있는 유일한 온라인 사이트 중 하나입니다.

다시 감사드립니다. Karol! :)

+0

대단히 환영합니다. 나는 항상 하나의 발견을 발표하는 것이 좋다. 다른 사람이 언제 google인지 알 수 없습니다. –