Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 684191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:47:22+00:00 2026-05-14T01:47:22+00:00

Reading up on WCF we have self hosting option available , one limitation here

  • 0

Reading up on WCF we have self hosting option available , one limitation here is we have to manage the host process lifecycle ourselves. What I am exploring here is to run the service without IIS and do a self hosting.

Few things come to mind
– How will request management work here. In case of IIS it manages the request and give control to dotnet on a particular thread. In absence of IIS do we need to write code ourselves to manage incoming requests ( say on a tcp port ) or WCF provides some classes to manage request and spawn threads to process each thread.

  • I am aware that in case of self hosting this needs to be a windows service. In case of self hosting how can me tap on the number of simultaneous requests on the sever , it can be managed by limiting the thread pool ? or we can configure this via wcf ?

Thanks
dc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:47:22+00:00Added an answer on May 14, 2026 at 1:47 am

    Self-hosting does not require a Windows service. You can self-host inside a console application if you so desire. It’s just that Windows services are a good solution for self-hosting if you require 24/7 access but do not want to, for whatever reason, use IIS.

    Managing the lifecycle of the host process is not a big deal. I use a Windows service to host a WCF service. I simply start my WCF service in the OnStart() callback of my Windows service, like so:

    private ServiceHost _host;
    protected override void OnStart(string[] args)
    {
        _host = new ServiceHost(typeof(CalculatorService));
        _host.Open();
    }
    

    Likewise, I close the WCF service in the OnStop() callback of my Windows service:

    protected override void OnStop()
    {
        if (_host != null) _host.Close();
    }
    

    This effectively ties the lifecycle of the WCF service to the lifetime of the Windows service. You could do something similar in any kind of application – console, Windows Forms app, etc. For example, in the OnLoad() callback of your Windows Forms app, start the ServiceHost for your WCF service and close it when exiting the app. Simple enough.

    WCF gives you a lot of flexibility on how to handle incoming requests. For example, you could make your WCF service a singleton, which means that you’ll have one and only one instance of your WCF service. In this case, all incoming requests are handled by this one instance. But you can also have your WCF service handle each incoming request with a new instance of your WCF service. This allows your service to scale better, but will likely require you to synchronize any access to your backend data storage, e.g., database. You can control this behavior using the InstanceContextMode property of the ServiceBehaviorAttribute on your WCF service.

    As I read your question again, it sounds like you’re just learning WCF, so I hope none of this has overwhelmed you. Check out my answer to this SO question for some links that you may find helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently reading quite a heavy WCF book. I have used it myself in production
I have a self-hosted WCF service and I'm having the following problem: 15 minutes
I am new to web development and WCF. I am reading some basics about
Reading on another forum I've came across the world of CSS Frameworks. The one
I have a WCF Web application that uses a WCF Class Library. My project
I'm trying to build a WCF self hosted service (eventually in a windows service)
I am new to WCF services. I have been working with WCF for over
I am reading WCF book.It states that the client can consume service running on
I saw in WCF they have the [OperationContract(IsOneWay = true)] attribute. But WCF seems
I am reading on internet about the difference between ASP.NET web service and WCF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.