简体   繁体   English

如何在服务器上使用WCF控制台应用程序?

[英]How to use a wcf console application on server?

I've made a basic wcf console app service that communicates over pipes.net. 我已经做了一个基本的wcf控制台应用程序服务,该服务通过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? 我应该以某种形式使用IIS来管理它吗?

Hosting in Windows Service is better for production use for it's autostart feature. Windows Service的自动启动功能使其更适合生产使用。 Hosting in IIS is easier and gives better maintainability and configuration. 在IIS中托管更容易,并提供更好的可维护性和配置。 IIS with App Fabric gives better monitoring of your service. 带有App Fabric的IIS可以更好地监视您的服务。

See this answer for help with choosing a way of hosting https://stackoverflow.com/a/9823604/2898090 请参阅此答案以获取有关选择托管方式的帮助, https://stackoverflow.com/a/9823604/2898090

Windows Service is better then console application. Windows Service比控制台应用程序更好。 You can define start properties for service (user, auto start, dependencies and fault behavior). 您可以定义服务的启动属性(用户,自动启动,依赖关系和故障行为)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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