Silverlight invokes a hosted WCF service on the console in a net.tcp way
(as a result of a recent study on a demo, prior to exposing the code structure, this is only where changes need to be explained) WCF4.0 makes the WCF service less complex, removes a lot of configuration information, the client needs only one service address, it can be developed under the system generated proxy class , you only need to change the address of the referencing configuration file at deployment time. But today I try to Silverlight it's a lot of trouble to connect the host to the WCF service on the console in a net.tcp way, and the communication between a WCF console server and a console client is simple and requires no configuration. But Silverlight if you want to reference this service, you must define metadata for the service to generate the proxy class for Silverlight, and an error occurs if you use the previous service directly.
WCF Service-side configuration
This is a simple service, no configuration, this time I want to completely by the configuration file to solve the problem of information disclosure, so the server is actually very simple
host = new ServiceHost(typeof(ChatService));
host.Open();
When the Silverlight reference results in a situation where no metadata is found, because there is no descriptive information about the service, no metadata does not allow the outside world to know the information about the service, so after repeated experiments, the service can be accessed normally, and there are two scenarios for the configuration file:
1, if no base address is configured, the address of the endpoint takes the full address
<system.serviceModel>
<services>
<service behaviorconfiguration= " Server.chatservicebehavior "
name=" Server.chatservice ">
<endpoint address=" Net.tcp://localhost : 4503/chatservice "
binding=" nettcpbinding "
contract=" Server.ichatservice "></endpoint>
<endpoint address= "Net.tcp://localhost:4503/chatservice/mex"
binding= "mextcpbinding" IMetadataExchange "
></endpoint>
</service>
</services>
<behaviors >
<serviceBehaviors>
<behavior name= "Server.chatservicebehavior" >
< Servicemetadata httpgetenabled= "false"/>
<servicedebug includeexceptiondetailinfaults= "false"/>
</behavior>
</serviceBehaviors>
</behaviors>