pruiz / Topshelf.Linux

Topshelf extensions allowing compatibility with mono/linux.
Apache License 2.0
42 stars 14 forks source link

Support Topshelf v4 #8

Closed nlowe closed 7 years ago

nlowe commented 7 years ago

The Problem

When installed alongside v4 of Topshelf, you get the following exception upon trying to use Topshelf.Linux:

Topshelf.HostFactory Error: 0 : An exception occurred creating the host, System.TypeLoadException: Could not load type 'Topshelf.Runtime.Linux.LinuxHostEnvironment' from assembly 'Topshelf.Linux, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost () in <filename unknown>:line 0
   at Topshelf.HostFactory.New (System.Action`1 configureCallback) in <filename unknown>:line 0
Topshelf.HostFactory Error: 0 : The service terminated abnormally, System.TypeLoadException: Could not load type 'Topshelf.Runtime.Linux.LinuxHostEnvironment' from assembly 'Topshelf.Linux, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost () in <filename unknown>:line 0
   at Topshelf.HostFactory.New (System.Action`1 configureCallback) in <filename unknown>:line 0

The signature of Topshelf.Runtime.hostEnvironment::InstallService has changed from

void InstallService(InstallHostSettings settings, Action beforeInstall, Action afterInstall, Action beforeRollback, Action afterRollback)

to

void InstallService(InstallHostSettings settings, Action<InstallHostSettings> beforeInstall, Action afterInstall, Action beforeRollback, Action afterRollback);

Steps to Reproduce

On a unix machine with mono installed, attempt to run a project that references the latest Topshelf and Topshelf.Linux. Run the program like so:

export MONO_LOG_LEVEL=debug
export MONO_LOG_MASK=type
mono --debug YourAssembly.exe

Notice the following warning from mono:

Mono: no implementation for interface method Topshelf.Runtime.HostEnvironment::InstallService(InstallHostSettings,Action`1<InstallHostSettings>,Action,Action,Action) in class Topshelf.Runtime.Linux.LinuxHostEnvironment

The exception mentioned above will be thrown.

Proposed solution:

  1. Update Topshelf.Runtime.Linux.LinuxHostEnvironment to use the new signature and release a new version of Topshelf.Linux
  2. Update the nuget dependencies to strictly depend on Topshelf 3.x
pruiz commented 7 years ago

I will make a new (interim) release restricting nuget dependencies to v3.*, and once this release is available at nuget, we can move master towards supporting v4. (This way anyone wanting to use this proyecto along with topshelf v3 can do so simply referencing the specific version supporting v3)