by
0
6
2,088
0
Top 1% !
Popular
Famous
Easy-to-find
Specified
OpenSource
Popularity: 9745th place

Published on:

LanguageCSharp
LicenseMIT_X11
MethodNameMain
OSWindows
OutputTypevoid

Main: Hosts the service.

<summary>
Hosts the service.
</summary>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/295272/Main--Hosts-the-service-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/// <summary> /// Hosts the service. /// </summary> public static void Main() { var serviceEndPointAddress = new Uri("https://localhost:3040/servicemodelsamples/service.svc"); var host = new ServiceHost(typeof(CalculatorService), serviceEndPointAddress); var binding = new WSHttpBinding(); binding.Security.Mode = SecurityMode.Transport; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; binding.Security.Message.NegotiateServiceCredential = true; binding.ReceiveTimeout = new TimeSpan(1, 0, 0); binding.MaxReceivedMessageSize = int.MaxValue; binding.ReliableSession.InactivityTimeout = new TimeSpan(1, 0, 0); host.Credentials.ServiceCertificate.SetCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectDistinguishedName, "CN=WCFServer"); host.AddServiceEndpoint(typeof(ICalculator), binding, serviceEndPointAddress); host.Open(); Console.WriteLine("Service started successfully at {0}", serviceEndPointAddress); Console.WriteLine("Enter any key to stop the service"); Console.Read(); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus