How to determine if I work in monoservice?

How can I discover that I am working under mono-service2? (in C # /. NET 3.5, running mono 2.6.7 on ubuntu 11)

Type.GetType("Mono.Runtime") tells me that I work in mono, so the part is fine. But Environment.UserInteractive always false under mono, which seems to be why I'm struggling to figure out if I'm really running mono-service2 - without a console / terminal.

+6
source share
2 answers

Environment.UserInteractive is the right solution, but unfortunately it is not currently implemented in Mono. I can take a look at it someday and update this answer;)

However, to find that you can probably use a hacker solution around this: the name assigned to the mono-service in m parameter will become the friendly domain name of the application for this service (at least according to the current mono-service source code ). So, when you start with this option, you can check:

 AppDomain.CurrentDomain.FriendlyName == "NameGivenToMParameter" 

If this is true, then your application obviously works with a mono service (with a given parameter). Print the value of the application domain name in the file to see if it really works (it is for me);) I do not know if this really fixes your problem.

+5
source
 if (Environment.OSVersion.Platform.Equals(PlatformID.Unix)) { } 
0
source

Source: https://habr.com/ru/post/907235/


All Articles