I have a WCF service and a console application (host). Host Code:
private static void StartHost() { Uri baseAddress = new Uri("http://localhost:8873/MyWCF/"); using (ServiceHost selfHost = new ServiceHost(typeof(MyWCF), baseAddress)) { selfHost.AddServiceEndpoint(typeof(WcfService.IMyWCF), new WSHttpBinding(), "MyWCF"); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; selfHost.Description.Behaviors.Add(smb); selfHost.Open(); Console.WriteLine("Press <ENTER> to terminate service."); Console.ReadLine(); selfHost.Abort(); selfHost.Close(); } }
It works, I can send messages to my service through the client application.
But if I press Enter and close the host, the WCF service continues to work! Requests from the client pass, responses are returned .. In the task manager, I see the IIS Express process running, in the tray in the list of running sites with IIS, I also see my service .. Why this happens, because I use the using construct and even call the Abort methods ( ) and Close () .. How can I completely stop the service? The problem is that the service uses some dll from the solution, the service does not "release" them. Thanks for any help, links
Client Code:
Uri baseAddress = new Uri("http://localhost:8873/MyWCF/"); BasicHttpBinding binding = new BasicHttpBinding(); var wcf = ChannelFactory<IMyWCF>.CreateChannel(binding, new EndpointAddress(baseAddress));
WCF-сервис и консольное приложение (хост)
...если я нажимаю Enter и закрываю хост, то WCF-служба продолжает работать
- why should the service have to do with a console and the fact of its closing? - tym32167Press Ctrl+F5 to run the service.
? - tym32167