TopShelf running on Mono/Linux

555 views
Skip to first unread message

Paul W

unread,
May 6, 2016, 7:11:14 AM5/6/16
to topshelf-discuss
Where is TopShelf with it's Mono compatibility?

I've seen previous posts from 2014 referring to issues with CreateToolhelp32Snapshot and I'm getting the same problem.

Topshelf v3.1.107.0, .NET Framework v4.0.30319.42000
Unable to get parent process (ignored) System.EntryPointNotFoundException: CreateToolhelp32Snapshot
at (wrapper managed-to-native) Topshelf.Runtime.Windows.Kernel32:CreateToolhelp32Snapshot (uint,uint)
at Topshelf.Runtime.Windows.WindowsHostEnvironment.GetParent (System.Diagnostics.Process child)

The service terminated abnormally System.NotImplementedException: The method or operation is not implemented.
at System.ServiceProcess.UnixServiceController.GetServices ()
at System.ServiceProcess.ServiceController.GetServices (System.String machineName)
at System.ServiceProcess.ServiceController.GetServices ()
at Topshelf.Runtime.Windows.WindowsHostEnvironment.IsServiceInstalled (System.String serviceName)
at Topshelf.Hosts.ConsoleRunHost.Run ()
at Topshelf.HostFactory.Run (System.Action`1 configureCallback)

Dru Sellers

unread,
May 6, 2016, 10:30:41 AM5/6/16
to topshelf...@googlegroups.com
Its something that we would very much love to have, but none of us (to my knowledge) are doing mono in production or even close to it. Just looking at the call stack, its clear that the service thinks its on Windows and is trying to call windows code. Are you running on windows but using Mono? Or are you using mono on linux?

I'm happy to help point things out if it was something we had a mono person to help out with.

--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul W

unread,
May 9, 2016, 9:06:53 AM5/9/16
to topshelf-discuss

Dru, thanks for your reply, any help would be very much appreciated.

 

The service I inherited was originally written in C# in Visual Studio as a Windows service before events dictated we needed to port it to run on Linux.

I installed a Mono Develop tool (XamarinStudio v5.10.1) and Mono for Windows (v3.2.3) onto a Windows box and the VS solution loaded in and runs ok in Run and Debug mode.

 

I then built and installed Mono for Linux (v4.4.0) from source code onto a RHEL box and copied the executable and dlls over and tried running using:

 mono <servicename>.exe

 

I don’t know if I’m supposed to use the ‘mono-service’ command to somehow ‘install the service’ like on windows?

 

And I’ve seen mention somewhere of a switch in the code something like ‘IsThisALinuxBox’. Is that a TopShelf call I need do you think as you said it appears to be calling windows code?

Dru Sellers

unread,
May 9, 2016, 10:35:16 AM5/9/16
to topshelf...@googlegroups.com
No, we should be detecting it automatically.


So, it seems that our check may no longer be valid.

Long Term:
I would probably be a good idea to have a Linux runtime as well as a windows runtime with all of the required classes etc.

but 

Paul W

unread,
May 10, 2016, 4:51:49 AM5/10/16
to topshelf-discuss

Dru,

 

This blog describes Linux hosting a TopShelf service using TopShelf.Linux nuget package and calling UseLinuxIfAvailable()

http://blog.amosti.net/self-hosted-http-service-in-c-with-nancy-and-topshelf/

 

http://www.symbolsource.org/Public/Metadata/NuGet/Project/Topshelf.Linux/1.0.4.4/Release/Default/Topshelf.Linux

 

Does this look like a solution to my issue do you think?

Paul W

unread,
May 10, 2016, 9:06:55 AM5/10/16
to topshelf-discuss
Update:

In the process of trying out the TopShelf.Linux package and UseLinuxIfAvailable() call I had to update to TopShelf v3.2.150.0 from v3.1.107.0.
This version update fixed the problem without the need for the TopShelf.Linux package.


I still get the CreateToolhelp32Snapshot error but it carries on and runs my service.

Thanks for your help.

Dru Sellers

unread,
May 10, 2016, 5:42:11 PM5/10/16
to topshelf...@googlegroups.com
I haven't used that package so I'm not sure. :/ Sounds like you got a fix though. :)
Reply all
Reply to author
Forward
0 new messages