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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:57:22+00:00 2026-05-16T11:57:22+00:00

I have a Windows Service written in C#. It includes a standalone console mode

  • 0

I have a Windows Service written in C#. It includes a standalone console mode as well, for debugging purposes. It works fine on almost every computer it’s been run on, but we ran into a situation where this service locks up when you try to start it, and then it gets killed because of timeout. But when running it in console mode on the same machine, it starts up fine.

It’s a pain to debug because I don’t actually have access to the machine this is happening on, I have to go through a human proxy. But after a bunch of trial and error debugging, I finally narrowed the cause down to assembly load. When it hits the first reference to any data type in a specific dll, it stops right there, according to the log file. It’s not even giving an exception, it just locks up.

[Edit] After further examination, it appears it’s not locking up permanently, it just takes about 40 seconds to actually finish loading the library, which is long enough for Windows services to decide to kill the process.

Any clue how to debug this kind of situation?

Here’s about the simplest solution that I can reproduce it with. “Before” shows up, but “During” and “After” do not.

private static void LoadAssembly()
{
    Log("During");
    MyNameSpace.MyClass x = new MyNameSpace.MyClass();        
}

static void Main(string[] args)
{
    try
    {
        // Leaving out code to handle command line parameters
        // ...
        //

        Log("Before");
        LoadAssembly();
        Log("After");
        if (Environment.UserInteractive)
        {
            Log("Starting in console mode");
            ConnectionManager.Listen();
        }
        else
        {
            Log("Starting in service mode");
            ServiceBase.Run(new RunAsService());
        }

    }
    catch (Exception ex)
    {
        Log(ex.ToString());
    }
}
  • 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-16T11:57:22+00:00Added an answer on May 16, 2026 at 11:57 am

    The assembly was taking 45 seconds to connect, it tries to connect to the internet to verify something about the assembly before loading it, but on that particular machine it’s blocked by the firewall. After 30 seconds of trying to start, Windows service manager gives up and kills the process.

    Moving the loading of the assembly until after the service has been started allowed it to start up properly (although with a 45 second delay before it starts responding).

    It looks like it was related to generating publisher evidence. From here http://msdn.microsoft.com/en-us/library/bb629393.aspx:

    We recommend that services use the element to improve startup performance. Using this element can also help avoid delays that can cause a time-out and the cancellation of the service startup.

    Putting the following in the app.config file got rid of the delay:

    <configuration>
        <runtime>
            <generatePublisherEvidence enabled="false"/>
        </runtime>
    </configuration>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Service written in C# that handles all of our external
i have a windows service written in .net 4 which doing jobs periodically using
Scenario I have a windows service written in C# that performs some processing based
I have a windows service that loads multiple handlers written by different developers. The
I have a windows service, written in c# and I need to run a
I have written a Windows service that I am needing to port over to
I have written a Windows service to collect information from all of our SQL
I have written a custom Windows Service that writes data to a custom Event
I have written a C# Windows Forms application, not a service (it is only
I have Windows Service written in C#. It starts two threads, one is pooling

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.