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

  • Home
  • SEARCH
  • 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 3438594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:12:24+00:00 2026-05-18T08:12:24+00:00

There are lots of examples how to install windows service in one line: ManagedInstallClass.InstallHelper(

  • 0

There are lots of examples how to install windows service in one line:

    ManagedInstallClass.InstallHelper(
      new[] { Assembly.GetExecutingAssembly().Location });

That works fine until service class is declared in exe module.
But the same code doesn’t work for me if service class is in referrenced assembly (not declared in executable, but in linked dll).

In such a case service is registered as well but can’t be started as it is registered with dll path and points to dll (“service is not a win32 executable” message appears in event log when I try to start that)

If I change GetExecutingAssembly().Location to executable path, then no installers are found and service is not registered at all.

Is it possible to put service class into referenced assembly and still have ability to register service with minimum effort?

Thank you in advance!

  • 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-18T08:12:25+00:00Added an answer on May 18, 2026 at 8:12 am

    here is some C# code that allows you to install/uninstall a service” manually” (without the need to declare custom RunInstaller attributes):

    static void InstallService(string path, string name, string displayName, string description)
    {
        ServiceInstaller si = new ServiceInstaller();
        ServiceProcessInstaller spi = new ServiceProcessInstaller();
        si.Parent = spi;
        si.DisplayName = displayName;
        si.Description = description;
        si.ServiceName = name;
        si.StartType = ServiceStartMode.Manual;
    
        // update this if you want a different log
        si.Context = new InstallContext("install.log", null);
        si.Context.Parameters["assemblypath"] = path;
    
        IDictionary stateSaver = new Hashtable();
        si.Install(stateSaver);
    }
    
    static void UninstallService(string name)
    {
        ServiceInstaller si = new ServiceInstaller();
        ServiceProcessInstaller spi = new ServiceProcessInstaller();
        si.Parent = spi;
        si.ServiceName = name;
    
        // update this if you want a different log
        si.Context = new InstallContext("uninstall.log", null);
        si.Uninstall(null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are lots of examples out there on this, but they
There are lots of examples around that show how to get a list of
There's lots of good material on Design Patterns out there that covers how you
There are lots of Fluent implementations out there now that work with Lambdas to
There are lots of questions that ask this or a similar question. They all
There are lots of examples on this site about adding to NSMutableArray and I
I am using data.table package quite a bit. There are lots of examples of
I know that there are lots of threads on gcc, particularly command gcc failed
There are lots of examples out there about how to open and use a
I know there are lots of delegate/func examples but I can't find any examples

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.