简体   繁体   English

如何配置WCF服务操作自动启动

[英]How to Configure WCF Service Operation Auto Start

I've developed a WCF service that has only one operation("start") and once it's called, It actively Listens to a specific port. 我已经开发了一种WCF服务,该服务只有一个操作(“启动”),一旦被调用,它就会主动侦听特定的端口。

I want to call this Operation every time the applicationpool is started. 我想在每次启动应用程序池时都调用此操作。 But i didn't find information about it. 但是我没有找到有关它的信息。

I've search intensively through the net and what i found was instructions about how to autostart the service, which does not include how to call the WCF Service Operation on Applicationpool Start. 我已经在网上进行了深入的搜索,发现的内容是有关如何自动启动服务的说明,其中不包括如何在Applicationpool Start上调用WCF服务操作。

I tried two approaches yet: 我尝试了两种方法:

One using a class with the appInitialize method inside the folder app_code of the deployed service. 一种将类与已部署服务的文件夹app_code内的appInitialize方法一起使用。 And in this class i called the start operation. 在这一堂课中,我称之为启动操作。 Didn't work, but the appInitialize don't even get called. 没用,但是appInitialize甚至没有被调用。

step-by-step appInitialize method 分步appInitialize方法

The second approach was through configuration of the file applicationHosts.config to configure Auto-Start for the service. 第二种方法是通过配置文件applicationHosts.config来配置服务的自动启动。 This also fails and the atribute "serviceAutoStartMode" were not recognized. 这也将失败,并且无法识别属性“ serviceAutoStartMode”。 However this is the start of the WCF Service and not WCF Service Operation call. 但是,这是WCF服务而不是WCF服务操作调用的开始。

step-by-step configurating Auto-Start to a WCF Service 分步配置对WCF服务的自动启动

So my question is: 所以我的问题是:

Is there any way of calling the WCF service operation on start of the application pool, iis, or other recommendable event? 在应用程序池,IIS或其他推荐事件启动时,是否有任何方法可以调用WCF服务操作?

Thanks in Advance 提前致谢

If you're using IIS 7+ and have App Fabric installed, you can use AppFabric Auto-Start feature. 如果您使用的是IIS 7+,并且已安装App Fabric,则可以使用AppFabric自动启动功能。

It's like Auto-Start you've read about, and it's easily configured in IIS. 就像您已经读过的“自动启动”一样,它很容易在IIS中进行配置。 This link has a good example: appfabric-auto-start-feature 这个链接有一个很好的例子: appfabric-auto-start-feature

Hope it helps. 希望能帮助到你。

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

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