[Mono-list] Making code conditional on "not running on mono"?

Ian MacLean ianm@ActiveState.com
Fri, 16 May 2003 11:29:33 +0900

We do somthing similar in nant. Except we use #ifdef mono.
Another way to test if you are on windows it to check the value of 
DirectorySeperatorchar. That won't help if you're trying to test for 
mono since you cold be on mono on wondows.


> If you are happy to have two seperate binaries and a common source code you
> could use the C# preprocessor. Surround the windows specific code with
> #endif
> and then define WINDOWS inside visual studio as one of the defines to pass
> to the compiler. This is what I am doing with an ASP.NET project I'm porting
> across to mono, and so far it is working quite well.
> Theo Spears
> -----Original Message-----
> From: mono-list-admin@lists.ximian.com
> [mailto:mono-list-admin@lists.ximian.com]On Behalf Of Stuart Ballard
> Sent: 14 May 2003 15:23
> To: mono-list@lists.ximian.com
> Subject: [Mono-list] Making code conditional on "not running on mono"?
> I have a C# program which uses some classes (specifically
> System.DirectoryServices) that aren't implemented in Mono. The code in
> question is not critical to the application and the majority of the
> functionality would work fine if it wasn't there. I can't remove the
> code entirely (because in some cases we actually do need the
> functionality) but I can't compile on Mono with it present, because the
> classes aren't found.
> Is there any way I can avoid having to have two different copies of the
> source code, one for Mono without the feature and one for MS.NET with
> the feature included?
> Thanks,
> Stuart.
> --
> Stuart Ballard, Senior Web Developer
> FASTNET - Web Solutions
> (215) 283-2300, ext. 126
> www.fast.net
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list