Hi,

There is no single way to determine which platform you're running on,
but here are a couple of ideas:

System.Environment.OSVersion.Platform will tell you if you're running
on Windows or not (but it will return Unix on iOS/Android/Mac/Linux).

* iOS: You can check whether monotouch.dll is in the list of loaded
assemblies. This assembly will always be loaded for all MonoTouch
processes.
* Android: You can probably do something similar to the iOS check, but
I don't know enough about Mono for Android to know exactly what you
should check for.
* Mac/Linux: I don't know how to distinguish between these two, but I
believe there is a native method you can p/invoke to get system
information.

I hope this helps,
Rolf


On Fri, Jun 1, 2012 at 11:07 AM, AnthonyLambert <[email protected]> wrote:
>
> Is there a way of at runtime (or compile time) telling what system the code
> is running on?
>
> I have some code which will run on Windows X86, Ios, Mac, Android.... I want
> to where possible build code that will run on all these platforms. Sometimes
> somecode will need to be conditional so it there a runtime API I can call
> that tells me what the platform is?
>
> I know at compile time I could set my own #defines like DEBUG and TRACE but
> I am sharing csprojs across platform so I would have to keep editing them.
>
> Any ideas?
>
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/Runtime-system-identification-tp4655153.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to