哪里是WCF服务的启动方法? [英] Where is the startup method of a WCF Service?

查看:335
本文介绍了哪里是WCF服务的启动方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行一个WCF服务的第一次调用之前的一些方法,我在哪里可以把这些方法呢?哪里是WCF服务的启动方式

I need to run some methods before the first call of a wcf service, where do i put those methods? Where is the startup method of a WCF Service?

OBS1:我的WCF服务将在IIS6运行。
OBS2:我使用的.NET Framework 4.0

Obs1: my WCF Service will run on a IIS6. Obs2: i'm using .net framework 4.0.

推荐答案

要做到这一点的方法之一是自我托管WCF服务(如不在IIS)。任何你想要的代码,这样,你就可以运行之前旋转起来的服务。

One way to do this is to self host your WCF services (as in not in IIS). That way you can run whatever code you want to before spinning up the services.

另一种方式是在每一个服务行为实现的构造函数添加静态方法调用。静态方法调用会做一个检查,以确保初始化已经完成。只要确保这个通话过程中处理多线程并发。

Another way is to add a static method call in the constructor of each service behavior implementation. That static method call would do a check to make sure that the initialization had been performed. Just make sure to deal with multi-threaded concurrency during this call.

这篇关于哪里是WCF服务的启动方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆