1
Vote

Avoidable exception in Cleanup() method

description

What if proxy was created, but never used? Then channel object (m_channel) was never created. Shouldn't it look like this:
    protected virtual void Cleanup()
    {
        try
        {
            ICommunicationObject co = (ICommunicationObject)m_channel;
    if (co != null) // <-- this line added
    {
        co.Closed -= InnerChannel_Closed;
        co.Closing -= InnerChannel_Closing;
        co.Faulted -= InnerChannel_Faulted;
        co.Opened -= InnerChannel_Opened;
        co.Opening -= InnerChannel_Opening;
        co.Close();
    }
        }

comments