1

I am developing a class library that will be used in both Unix and Windows.

I had a case where Mono's System.Web.HttpClient adds an unwanted header (that .NET Windows does not). But I found a workaround that I can use to prevent side effect of Mono runtime.

To do that I need to find out if the binary is running on Mono runtime and I can simply add an if statement and distribute my DLL afterwards.

Is there such flag / function to figure that out? Thanks.

ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
  • 1
    I read somewhere you can use Type.GetType("Mono.Runtime") to check. I'm not sure if it's the best way to do it though! - I also found this link which might be helpful http://mono.wikia.com/wiki/Detecting_the_execution_platform – GracelessROB Feb 13 '14 at 00:20

1 Answers1

3

You can use reflection to check if the Mono.Runtime type is defined. Like this:

Type.GetType("Mono.Runtime")

The mono project FAQ recommends this method to detect if you are running in mono

Good luck!

GracelessROB
  • 1,048
  • 8
  • 11