If you disable the service first and then disable the client
The client's Channel. Close () will report an exception:
"The communication object, system. servicemodel. channels. servicechannel, cannot be used for communication because it is in the faulted State ."
Open the client if the service is not started.
The client's Channel. open () will report an exception:
"The endpoint was not found. Please ensure that you can connect to the Internet using http port 80 and TCP port 808 ."
The namespace of the client and service properties is inconsistent.
For example:
Client:
[Servicecontract (name = " Iechocontract " , Namespace = " Http://samples.microsoft.com/ServiceModel/Relay/ " )]
Public Interface Iechocontract
{
[Operationcontract]
String echo ( String Text );
}
Server:
// Note that an echo is added.
[Servicecontract (name = " Iechocontract " , Namespace = " Http://samples.microsoft.com/ServiceModel/Relay/Echo " )]
Public Interface Iechocontract
{
[Operationcontract]
String echo ( String Text );
}
An exception is reported when the client executes channel. Echo (input:
"The message with Action 'HTTP: // samples.microsoft.com/servicemodel/relay/iechocontract/echo' cannot be processed at the specified er, due to a contractfilter mismatch at the endpointdispatcher. this may be because of either a contract mismatch (mismatched actions between sender and caller) or a binding/security mismatch between the sender and the caller. check that sender and receiver er have the same contract and the same binding (including security requirements, e.g. message, transport, none )."
Avoid contract and behavior paste & copy Error
If servicecontract is used for a place that should use servicebehavior, for example:
// Shocould be [servicebehavior (name = "echoservice", namespace = Http://samples.microsoft.com/ServiceModel/Relay/ )]
[Servicecontract (name = " Iechocontract " , Namespace = HTTP: // Samples.microsoft.com/servicemodel/relay/)]
Public Class Echoservice: iechocontract
{
Public String Echo ( String Text)
{
Console. writeline ( " Echoing: {0} " , Text );
Return Text;
}
}
When a new host is created, servicehost host = new servicehost (typeof (echoservice), address); // an exception is thrown.
Exception information:
"the service class of Type Microsoft. servicebus. samples. echoservice both defines a servicecontract and inherits a servicecontract from type Microsoft. servicebus. samples. iechocontract. contract inheritance can only be used among interface types. if a class is marked with servicecontractattribute, it must be the only type in the hierarchy with servicecontractattribute. consider moving the servicecontractattribute on type Microsoft. servicebus. samples. iechocontract to a separate interface that type Microsoft. servicebus. samples. iechocontract implements. "