• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

C# wcf void main

I have a C# WCF project (vs2010u) and I need to be able to point to a start up method.  Most applications have static void main, but I don't see that here.

How can I get a WCF service to automatically execute a particular method on startup?

Also, is there a close event that I can have it respond to as well?

Thanks.

0
hpdvs2
Asked:
hpdvs2
  • 2
  • 2
1 Solution
 
käµfm³d 👽Commented:
How are you hosting the service--in IIS or in a self-hosted setup (e.g. console application or windows service)?
0
 
hpdvs2Author Commented:
I've been using debug mode, in VS2010 so far, just now paying attention to the fact it was going through IIS.  However, I'm planning on building this for a console app.  I'm guessing that the console app will call it on its void main.
0
 
käµfm³d 👽Commented:
I've been using debug mode, in VS2010 so far
If by that you mean you created the service, and only the service (i.e. no other project like a Console project), then you are simulating running the app on IIS, albeit using VS' built-in web server Cassini.

However, I'm planning on building this for a console app.  I'm guessing that the console app will call it on its void main.
That depends on what you mean. If you mean you are creating a Console app to host the application (as opposed to using IIS), then yes your console app will have a main and inside that function you will call code to start your service. If instead you mean that you will be creating an app that will be consuming your service (i.e. using its function calls), then that is an entirely separate application.

See if this link clears up your confusion:  http://msdn.microsoft.com/en-us/library/bb332338.aspx#msdnwcfhc_topic2
0
 
hpdvs2Author Commented:
I'll add this line:  I didn't realize some of the difficulties in producing the console app version.  The first I tried was windows service, which was a huge pain.  Then I tried console app from http://msdn.microsoft.com/en-us/library/ms731758.aspx, and then called the initializer from the main() in the console app.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now