tags:

views:

92

answers:

1

My application is leaking channels.Apperently some channels are not being closed correctly but i can't find where. At some point my application hangs because there is no channel left to open.

Is there some method to get all open channels in the servicemodel so i c an backtrace the problem?

A: 

If you're not already doing something similar, make sure you're reusing/recycling exising channels with some code like this in a base class for your services:

Protected ReadOnly Property MyService() As MyServiceClient
    Get
        ' Initialise My Service and return it
        If m_objMyService Is Nothing OrElse m_objMyService.State = CommunicationState.Closed OrElse m_objMyService.State = CommunicationState.Faulted Then
            m_objMyService = MethodToGetServiceClient(Of MyServiceClient, MyService)()
        End If
        Return m_objMyService
    End Get
End Property
Tanner
And make absolutely sure to close and dispose of the channel proxies when you don't need them anymore
marc_s