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

Jonathan Pryor jonpryor@vt.edu
14 May 2003 22:55:57 -0400


Yes, though it may require some code refactoring and use of Reflection. 
Basically, move all of the System.DirectoryServices code into its own
assembly, dynamically load the assembly at run time, and dynamically
invoke methods in the loaded assembly.

This may not be ideal, as it replaces compile-time type-safe code with
dynamic, reflection-using code, but it should work for the short term.

 - Jon

On Wed, 2003-05-14 at 10:22, Stuart Ballard wrote:
> 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.