Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the startup method of a WCF Service?

Tags:

c#

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: my WCF Service will run on a IIS6. Obs2: i'm using .net framework 4.0.

like image 903
Vinicius Ottoni Avatar asked Mar 19 '12 13:03

Vinicius Ottoni


People also ask

How do I start WCF?

Press Ctrl + F5 to run the service. Open WCF Test Client. To open WCF Test Client, open Developer Command Prompt for Visual Studio and execute WcfTestClient.exe.

What is the entry point of WCF service?

webserver.exe is located under your . NET framework installation directory (C:\WINDOWS\Microsoft.NET\Framework\v2. 0.50727 or C:\Program Files\Common Files\Microsoft Shared\DevServer), and it may be called a different name such as webdev.

What are 3 basic WCF configuration required for hosting a WCF service?

There are three types of hosting environments for WCF services: IIS, WAS, and self-hosting. The term “self-hosting” refers to any application that provides its own code to initialize the hosting environment. This includes console, Windows Forms, WPF, and managed Windows services.

How do I host a WCF service in a managed Windows service?

The Windows service should appear in Services as "WCFWindowsServiceSample". The WCF service can only respond to clients if the Windows service is running. To start the service, right-click it in the SCM and select "Start", or type net start WCFWindowsServiceSample at the command prompt.


1 Answers

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.

like image 74
RQDQ Avatar answered Sep 22 '22 16:09

RQDQ