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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:59:19+00:00 2026-05-20T13:59:19+00:00

I have a windows service created using the new … c# service menu in

  • 0

I have a windows service created using the “new … c# service” menu in VS 2010. In the constructor I have:

TextWriterTraceListener tr1 = new TextWriterTraceListener( System.IO.File.CreateText("d:\\output\\test.log"));
Trace.Listeners.Add(tr1);
Trace.WriteLine("Created");

Setting the service to run in either LocalService or LocalSystem accounts (WinXP) I get the file created when the service starts, but it’s always empty. Adding a Flush() call to the destructor doesn’t help. I have more trace calls in the OnStart/OnStop/OnPause/OnContinue methods.

(edit) I have trace and debug enabled in the project – the trace output file is being created, it’s just empty.

The service will pull records out of a database and write files to disk for a messaging system we have to interface with. So the log file problem is the just first instance of a broader problem – I need to be able to write to a user-selected messaging directory.

This looks like the symptoms in another question but also I get the problem as LocalSystem (which I thought had too many permissions so was deprecated).

  1. What am I doing wrong with the trace calls? (why is the file created but nothing written to it?)
  2. If I want my service to run in the LocalService account is there some way to get the installer to give it permission to write to a folder/subtree?
  3. Or should I be running the service as LocalSystem?
  4. is this re-implementation of [Debug.Launch/EnsureWriter][2] a sane solution? I’m more inclined to say “why is the writer null” than paste code from elsewhere like that.

thanks for any help

  • 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-20T13:59:20+00:00Added an answer on May 20, 2026 at 1:59 pm

    Are you sure you have the TRACE symbol defined for your project? All the System.Diagnostics.Trace code is conditionally compiled in based on this symbol. Note that you will still need to flush the trace output to ensure all the lines are written (or else set Trace.AutoFlush to true).

    As a side note, I would recommend against the use of the static Trace methods and suggest at least using System.Diagnostics.TraceSource.

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

Sidebar

Related Questions

I have created an OData/WCF service using Visual Studio 2010 on Windows XP SP3
I have created and started windows service Service1 (with exe as MyService.exe) using c#
I have created a C# web service using visual studio to stop the windows
I have created a windows service by using (Visual Studio 8) and installed it
I have created a Windows Service in VB.net for building xML from a database.
I have created a C# Windows service but it fails to start. I get
I have created a simple windows service that periodically checks a remote database via
We have created a WCF service hosted in a windows service that handles Authentication
Currently, I have a project with a Windows Service. I also created another Setup
We have a Windows Service created in .Net 4.0, the services parses large text

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.