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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:24:41+00:00 2026-05-23T01:24:41+00:00

I have a windows service which i can’t run or start, only install or

  • 0

I have a windows service which i can’t run or start, only install or directly debug the project.

This is my main:

namespace MyService
{
    public static class Program
    {
        private static void Main()
        {
            var ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service() };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
        }
    }
}

And this is my Service:

public partial class Service : ServiceBase
    {
        private dynamic _serviceHost;

        public Service()
        {
            this.InitializeComponent();
            this.ServiceName = "MyService";
            this.CanShutdown = true;
            this.CanStop = true;
        }

        private static string HostName
        {
            get
            {
                string hostName = Dns.GetHostName();
                IPHostEntry ipHostEntry = Dns.GetHostEntry(hostName);
                return ipHostEntry.HostName;
            }
        }

        protected override void OnStart(string[] args)
        {
            var worker = new Thread(this.InitializeHost) { Name = "Host", IsBackground = false };
            worker.Start();
        }

        private void InitializeHost()
        {
            var baseAddress = new Uri(string.Format("net.tcp://{0}:{1}/MyService", HostName, "9020"));
            var mexAddress = new Uri(string.Format("http://{0}:{1}/MyService", HostName, "8000"));
            var cache = Factory.Create<string>("MyAssembly.MyClass", "MyAssembly");
            var service = new ServiceWcf<string>(cache);
            using (this._serviceHost = new Host<string>(service))
            {
                this._serviceHost.Open(baseAddress, mexAddress);
            }
        }

        protected override void OnStop()
        {
            this._serviceHost.Dispose();
        }
    }

When I try to run without debugging or to start after installing the service i get the following error:

Run (directly or through VS):
Error while trying to run project: Unable to start program
‘C:\path\to\my\projects\bin\Release\MyService.exe’.
The system cannot find the specified path.

Service start:
The service “MyService” on local cimpouter could not be started.
Error 3: The system cannot find the specified path.

I have no clue where the error could be.

EDIT:

private void InitializeComponent()
        {
            this.serviceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            this.serviceInstaller = new System.ServiceProcess.ServiceInstaller();
            // 
            // serviceProcessInstaller
            // 
            this.serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
            this.serviceProcessInstaller.Password = null;
            this.serviceProcessInstaller.Username = null;
            // 
            // serviceInstaller
            // 
            this.serviceInstaller.ServiceName = "MyService";
            this.serviceInstaller.DisplayName = "My service";
            this.serviceInstaller.Description = "My service is awesome.";
            this.serviceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
            // 
            // ProjectInstaller
            // 
            this.Installers.AddRange(new System.Configuration.Install.Installer[] {
            this.serviceProcessInstaller,
            this.serviceInstaller});

        }
  • 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-23T01:24:41+00:00Added an answer on May 23, 2026 at 1:24 am

    I think this is just an issue with how the service has been registered – i.e. it’s in the wrong place.

    run an installutil /u [service] from a VS command prompt to uninstall any service entries you already have.

    CD over to the folder where you want to run the service from – be careful here, you will have both a debug and a release build – which one do you want to be installed in the services list?

    Use installutil /i [service] on the exe to reinstall.

    Now it should work.

    I think you might have registered the debug build first and have subsequently run a Clean operation on the build before building the Release version; thus deleting the original executable. Either that – or perhaps you moved the project after originally developing it?

    Many of the developers I work with use a different folder for their local service installations that is always the same; they then deploy either a debug or release version to it; thus when they want to switch between the two they just copy different file versions over. I don’t do this – I only ever register the debug build; but then I have more work to do when testing the release build 🙂

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

Sidebar

Related Questions

I have been made a windows service.in which i have been added project installer.in
I have an importer process which is running as a windows service (debug mode
I have a windows service project which I added to a few other projects.
I have a WCF service which is hosted in a Windows Service. This Windows
I have a Windows Service which is basically accessing a mailbox and reading the
I have a windows service which fetches data from various datasources and build a
I have two windows application, one is a windows service which create EventWaitHandle and
I have a Windows Service application which uses a Threading.Timer and a TimerCallback to
I have a windows service application which works using remoting. It is used to
I have made a new windows service which works fine using barebone code (just

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.