How can I conditionally compile my C# for Mono vs. Microsoft .NET?

The Mono compiler defines __MonoCS__

BUT, BUT, BUT, the whole point of Mono is that you can take an assembly that you built with VS and run it on Mono, or vice versa.

It seems to me that if you need to have Mono vs MS.NET differences, then you need to be making those decisions at run-time.

The standard way to detect Mono at Runtime is:

bool runningOnMono = Type.GetType ("Mono.Runtime") != null;

Leave a Comment