The WCF server I createdProgramThe customer cannot be generated all the time with the svcutil command
Error message:
Metadata contains reference that cannot be parsed: "net. TCP: // 127.0.0.1: 6987/do"
Net. TCP: // 127.0.0.1: 6987/do
Solution Law 1:
Add the following in the program:Code
If (host. description. behaviors. Find <system. servicemodel. description. servicemetadatabehavior> () = NULL)
{
Bindingelement elemnt = new tcptransportbindingelement ();
Custombinding bind = new custombinding (elemnt );
Host. description. behaviors. Add (new system. servicemodel. description. servicemetadatabehavior ());
Host. addserviceendpoint (typeof (system. servicemodel. description. imetadataexchange), bind, "mex ");
}
Solution 2
How to change the server configuration file is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. servicemodel>
<Services>
<Service name = "leleapplication1.do" behaviorconfiguration = "idobehavior">
<Endpoint address = "duplex" binding = "nettcpbinding" Contract = "leleapplication1.ido">
<Identity>
<DNS value = "localhost"/>
</Identity>
</Endpoint>
<! -- Metadata endpoints -->
<! -- The metadata exchange endpoint is used by the Service to describe itself to the client. -->
<! -- This endpoint does not use secure binding. You should ensure security or delete it before deployment. -->
<Endpoint address = "mex" binding = "nettcpbinding" Contract = "imetadataexchange"/> // to use svcutil to generate client files, you must include this code
</Service>
</Services>
// To generate a client file using svcutil, the following code must be included:
<Behaviors>
<Servicebehaviors>
<Behavior name = "idobehavior">
<! -- To avoid metadata leakage,
Set the following value to false before deployment and delete the above metadata endpoint -->
<! -- Service metadata publishing and related information
Attribute description:
The value of the httpgetenabled-bool type indicates whether to allow the http get method to obtain the WSDL metadata of sevice.
Httpgeturl-If httpgetenabled is true, this attribute indicates the URL used to publish the Service's WSDL,
If this attribute is not set, add? WSDL -->
<Servicemetadata httpgetenabled = "true" httpgeturl = "http: // 127.0.0.1: 64987/do"/>
<! -- Receives fault exception details for debugging,
Set the value to true. Before deployment
Set to false to avoid leakage of exception information -->
<Servicedebug includeexceptiondetailinfaults = "false"/>
</Behavior>
</Servicebehaviors>
</Behaviors>
</System. servicemodel>
</Configuration>
the address written after svcutil is: Address in httpgeturl set in servicemetadata configuration section