How to use a wcf console application on server?
-
20-12-2019 - |
Question
I've made a basic wcf console app service that communicates over pipes.net. The logic works with my main application, but I need to keep it seperate for business reasons
It does one of these
Uri baseAddress = new Uri(@"net.pipe://localhost/Server");
Uri baseHttpAddress = new Uri(@"http://localhost:9080");
using (var host = new ServiceHost(typeof(CPLConversionService), baseAddress, baseHttpAddress))
{
host.Open();
Console.WriteLine("The CPLConversionService is available. ");
Console.WriteLine("Press <Enter> to stop the service. ");
Console.ReadLine();
host.Close();
}
Anyway, it is okay to put this up on a web-server and let it run long term? Should I manage it using IIS instead in some form?
Solution
Hosting in Windows Service is better for production use for it's autostart feature. Hosting in IIS is easier and gives better maintainability and configuration. IIS with App Fabric gives better monitoring of your service.
See this answer for help with choosing a way of hosting https://stackoverflow.com/a/9823604/2898090
OTHER TIPS
Windows Service is better then console application. You can define start properties for service (user, auto start, dependencies and fault behavior).