static void TraceInnerChannelFailure(TChannel innerChannel, EndpointAddress to, Uri via, Exception exception)
 {
     if (innerChannel == null && TD.InnerChannelCreationFailedIsEnabled())
     {
         TD.InnerChannelCreationFailed(to.ToString(), via.ToString(), exception);
     }
     else if (innerChannel != null && TD.InnerChannelOpenFailedIsEnabled())
     {
         TD.InnerChannelOpenFailed(to.ToString(), via.ToString(), exception);
     }
 }
            static Exception HandleCommunicationException(DiscoveryChannelBuilderAsyncResult thisPtr, CommunicationException e)
            {
                if (thisPtr.innerChannel != null)
                {
                    thisPtr.innerChannel.Abort();

                    if (TD.InnerChannelOpenFailedIsEnabled())
                    {
                        TD.InnerChannelOpenFailed(
                            thisPtr.currentEndpointDiscoveryMetadata.Address.ToString(),
                            GetVia(thisPtr.innerChannel).ToString(),
                            e);
                    }

                    thisPtr.innerChannel = null;
                }

                return(null);
            }