简体   繁体   中英

How to use a wcf console application on server?

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?

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

Windows Service is better then console application. You can define start properties for service (user, auto start, dependencies and fault behavior).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM