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 6702309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:02:21+00:00 2026-05-26T07:02:21+00:00

A little background info – I’m trying to host a RESTful WCF service on

  • 0

A little background info –
I’m trying to host a RESTful WCF service on Azure. As I understand, unless I have the ASP.NET type hosting on the role, I don’t really need the global.asax class (which has the application_start method).

From basic prototyping, all I needed was the svc file and the implementation behind it and it automatically gets initialized on role startup (I mean, hosted up on IIS).This is great because I need no extra code other than web.config and my service is up and running. I don’t need to create a new service host and start listening on it, etc. I’m able to deploy the role and POST messages to my service.

The problem –
I have custom logging and initialization classes implemented that I need to initialize when my service starts up. I configured my service to be a singleton and I’m not sure where I should put my custom initialization components.

Without an explicit application start method and my service configured as a singleton, can I assume that when the first request comes in, my service constructor gets called? (along with all my custom initialization?).

  • 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-26T07:02:22+00:00Added an answer on May 26, 2026 at 7:02 am

    can I assume that when the first request comes in, my service constructor gets called?

    Yes, but you should ask yourself whether you really want your service to run as a singleton. If you’re happy with this then it will work fine; if you don’t want it to run as a singleton then you should look into Russell’s answer using a custom factory.

    Look at Should WCF service typically be singleton or not? for some discussion about whether WCF services should be singletons. You need to decide for your situation, but generally WCF services are not singletons unless they need to be.

    To implement a custom factory, see this MSDN link Extending Hosting Using ServiceHostFactory. As the link describes, extend the service host factory like so

    public class DerivedFactory : ServiceHostFactory
    {
       public override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
       {
          return new ServiceHost(t, baseAddresses )
       }
    }
    

    And then specify your factory in the ServiceHost directive

    <% @ ServiceHost 
         Service="MyNamespace.MyService" 
         Factory="MyNamespace.DerivedFactory" %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I begin my question a little background info. I have the WCF service
Here's a little background info on what I'm trying to do: I have a
Giving a little background info: Details.cshtml contains a title (uses model Category), I have
First a little background info: I have UIViewController that contains a UITableView. In the
Little Background: I have csv file which has lots of rows and each row
A little background: I have a perl script which is performing a number of
First a little background: I have already managed to connect to a Microsoft SOAP
First I will give a little background info so this question isn't completely without
I need to outline a little bit of background info for context. Please bear
Relevant background info I've built a little software that can be customized via a

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.