Install Windows .net service with lib folder

I would like to create an installation for my windows service. My Windows service dll is located in the / lib / folder.

I added the installer class service. And added a custom action to the installation project.

The problem is that when I try to install the service - it fails with the error: Error 1001. Unable to get installer types in ...

This error occurs because the dlls are not in the same directory as the .exe service. I use probing in the service configuration and the util installation does not recognize this probing.

I wanted to find work for this problem and tried in many ways to create a service using the service controller (sc.exe). Trying to run it as a custom action using cmd.exe. Etc ..

This should be a common problem ... will anyone find a suitable solution for this?

+5
source share
3 answers

I had the same problem and none of the options suggested in this post or MSDN helped. I decided another solution:

Using Reflector on InstallUtil.exe, I found InstallUtil to be just a thin shell to invokeSystem.Configuration.Install.ManagedInstallerClass.InstallHelper(args) inside the try / catch block (it also sets the current thread UI culture and displays Copyright). ManagedInstallerClass.InstallHelperIt is located in the System.Configuration.Install.dll assembly, accessible to everyone. So I just modified Program.Mainmy service method to allow the installation. See the quick and dirty code below:

static class Program
{
    static void Main(string[] args)
    {
        if (args != null && args.Any(arg => arg == "/i" || arg == "/u"))
        {
            // Install or Uninstall the service (mimic InstallUtil.exe)
            System.Configuration.Install.ManagedInstallerClass.InstallHelper(args);
        }
        else
        {
            // Run the service
            System.ServiceProcess.ServiceBase[] ServicesToRun;
            ServicesToRun = new System.ServiceProcess.ServiceBase[] 
            { 
                new MyService() 
            };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
        }
    }
}

InstallUtil.

+2

you can add a test path in your configuration - this is a hint for the runtime where to look for the assembly http://msdn.microsoft.com/en-us/library/823z9h8w%28v=vs.80%29.aspx

0
source

All Articles