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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:07:40+00:00 2026-05-25T12:07:40+00:00

I am creating asp.net web service. I have one class, whose static constructor is

  • 0

I am creating asp.net web service. I have one class, whose static constructor is not getting called when I try to initialize object of that class. I am not able to understand this behavior. Inside static constructor I am reading values from web.config file.

Here is part of code :

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    AppController extractor;

    public Service()
    {
        try
        {
            extractor = new AppController();
        }
        catch(Exception ex)
        {
            // I am not getting exception at this point.
        }
    }
}

public class AppController
{
    static string converterBatchFilePath = null;
    static string personalProfileOutputFolderPath = null;

    static AppController()
    {
        // reading some settings from web.config file
        try
        {
            converterBatchFilePath = ConfigurationManager.AppSettings["WordToTextConverterBatFilePath"];
        }
        catch(Exception ex)
        { // }
    }
    public AppController()
    {
        // do some initialization
    }
}

While debugging web service I noticed that only instance constructor is getting called and control never goes to static constructor.

Anyone know why this is happening?

I am using VS 2008 Express edition and C#.

EDIT

Actually this AppController is console based project. I have added that project as a reference inside Web service project and then using it. If I use AppController from command line, it works fine, but its not working from inside web service project.

  • 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-25T12:07:41+00:00Added an answer on May 25, 2026 at 12:07 pm

    My guess is that it’s called before you expected it to be called. If you have already debugged your site but not recycled the AppPool, it’s very likely that the static constructor has already been run.
    Similarly anything that accesses any static members will also call the static constructor if it hasn’t already been called.

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

Sidebar

Related Questions

I have an irritating problem, I'm creating an asp.net web service; this service should
I have a ASP.NET SOAP web service whose web method creates a PDF file,
I am creating a web service in asp.net 2.0 with c# and have a
I am creating a web service in ASP.Net. I have looked and can't find
I'm creating a web service that'll be called from a web form in asp.net.
What choices do I have for creating stateful dynamic content in an ASP.Net web
Yesterday I began learning WCF by porting an existing ASP.NET Web Service. Creating the
I'm creating an asp.net web application. In the web application I have a web
I have an ASP.NET 2.0 web service and am using it in (among other
I am creating an ASP.NET web service that implements a specific existing WSDL. There

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.