• 2k
  • 4
  • 158

Pass EndpointAddress to ChannelFactory with EndPointConfigName

Sep 25 2020 6:09 PM
For some scenarios, I want to pass the endpoint address to my Channel Factory. But want to use the app config address in other situations.
My Code:
  1. if (endPointAddress != null && endPointAddress != string.Empty)  
  2. channelFactory = new ChannelFactory<T>(clientEndpointName, new EndpointAddress(endPointAddress));  
  3. else  
  4. channelFactory = new ChannelFactory<T>(clientEndpointName);  
When endpoint address is passed (eg: net.tcp://
It gives me an error
Dispatch transaction request failed. ---> System.ServiceModel.Security.MessageSecurityException: Identity check failed for outgoing message. The expected DNS identity of the remote endpoint was '' but the remote endpoint provided DNS claim XXXXX. If this is a legitimate remote endpoint, you can fix the problem by explicitly specifying DNS identity XXXXX as the Identity property of EndpointAddress when creating channel proxy.
Screenshot of App config:
Any help is appreciated.

Brought to you by:

Answers (2)