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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:36:59+00:00 2026-05-15T12:36:59+00:00

I have a small console app containing a web server written in c#. When

  • 0

I have a small console app containing a web server written in c#. When trying to convert it to windows service, i get a error 1053, and when i view the error log it shows:

Application: YCSWebServerService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.DirectoryNotFoundException
Stack:
   at HttpServer.Resources.FileResources.Add(System.String, System.String)
   at HttpServer.Resources.FileResources..ctor(System.String, System.String)
   at YCSWebServer.WebServer..ctor(SerialCommunication.SerialCommunicationWrapper, YCSInterfaces.IBuilder, SerialCommunication.SerialCommunication)
   at YCSConfiguration.Builder..ctor()
   at YCSWebServerService.YCSWebServerService..ctor()
   at YCSWebServerService.Program.Main()

which is due to the following code:

server = new Server();

// Where to find the html page to render
server.Resources.Add(new FileResources("/", ".\\Webpages"));
server.Add(new FileModule(server.Resources, false));

//Create a http listener
HttpListener listener = HttpListener.Create(IPAddress.Any, 8888);

// use one http listener.
server.Add(listener);

server.RequestReceived += ServerRequestReceived;

// start server, can have max 10 pending accepts.
server.Start(10);

I have trying setting a relative path to where my html files are located, and i have trying giving it a fixed path fx: c:\webpages, but without success. I always get the same error.
Do i have set some kind of permission/security in order for my service to access this folder??
The webserver is based on a codeplex project: http://webserver.codeplex.com/

My onstart and onstop methods:

public partial class YCSWebServerService : ServiceBase
    {
        private Builder _builder;
        public YCSWebServerService()
        {
            InitializeComponent();
            _builder = new Builder();
        }

        protected override void OnStart(string[] args)
        {
            _builder.Start();
        }

        protected override void OnStop()
        {
            _builder.Stop();
        }
    }
  • 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-15T12:37:00+00:00Added an answer on May 15, 2026 at 12:37 pm

    I had this exact same problem about a week ago. The problem is there is no “startup path” setting for windows services, so relative paths to files in the solution won’t work.

    This function gets the folder the service is executing in, you need to prepend that to "\\Webpages" and not use .\\WebPages"

    Hope this helps

    private static string ExecutingFolder()
    {
        string exeUri = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
        Uri uri = new Uri(exeUri);
        string physicalExePath = uri.LocalPath;
        return IO.Path.GetDirectoryName(physicalExePath);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small utility script written as .Net/C# console app purely for the
I have a small application written in c# as a console app that I
I've written up a small console utility. Throughout the application, I have used slf4j/log4j
I have a small C# console app I am writing. I would like the
I have created a C# web service using visual studio to stop the windows
I've written a small C# console app that is used by many users on
I have a Web App and a service sitting on the same machine and
I am writing a small console app which have to overwrite a txt file
I have created a small chatting application in C#, and started as a Console
have small problem, and would very much appreciate help :) I should convert byte

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.