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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:08:15+00:00 2026-05-24T19:08:15+00:00

I am debugging a Windows service (by hitting F5 in Visual Studio 2010) using the following

  • 0

I am debugging a Windows service (by hitting F5 in Visual Studio 2010) using the following code:

In Program.cs file:

static void Main() {

    if (!Environment.UserInteractive) {
        // We are not in debug mode, startup as service

        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] { new MyServer() };
        ServiceBase.Run(ServicesToRun);
    } 
    else {
        // We are in debug mode, startup as application

        MyServer service = new MyServer();
        service.StartService();
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }
}

And in MyServer.cs file:

public void StartService() {
    this.OnStart(new string[0]);
}

In the past, I used the Debug.WriteLine("xxx") line without any problem in all my service code, but now I noticed that all Debug.WriteLine() lines are not called anymore.

I clearly see that the debugger is jumping over these lines when I debug with Step Into (F11) – (thus, there is no output text on the output Window), whereas the service is correctly started in “debug mode”.

I don’t understand why the Debug code won’t be called. Suggestions?

I build my solution in debug mode (Define DEBUG constant is checked), but I noticed that the code surrounded by #if DEBUG ... #endif is not called. That is weird…

  • 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-24T19:08:17+00:00Added an answer on May 24, 2026 at 7:08 pm

    Seems the Debug symbols are missing.

    1. Clean your solution, restart Visual Studio, rebuild the solution.
    2. Make sure the Configuration Manager is in Debug mode.
    3. Check in Tools > Options > Debugging and Uncheck “Enable Just My Code”

    Happened to me and this seemed to help.

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

Sidebar

Related Questions

I'm debugging a Windows Forms client that calls a WCF service in Visual Studio
I have made a new windows service which works fine using barebone code (just
What I have installed... Windows Vista Ultimate Service Pack 1 Visual Studio 2008 Service
Debugging asp.net websites/web projects in visual studio.net 2005 with Firefox is loads slower than
I have a Windows service that I'd like to gather some debugging data on
I've got a Visual Studio 2008 solution with a WCF service, and a client.
I have a managed code Windows Service application that is crashing occasionally in production
I have a Windows Service that hangs when opening an OLEDB-connection to an Excel-file,
I've been creating a an application with C# using W2k8+IIS7/SQLExpress 2008/Web Service/Windows Client. I'll
I have the following code: public static long CreateVendorsEmailJob(List<Recipient> recipients, string subject, string body)

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.