views:

37

answers:

1

Is there a compilation symbol to detect if it's running on a compact framework platform

+4  A: 

You have a discontinuity in your question. You're asking about a compile symbol, so something that exists only at design time, and detecting a condition while running. So the question for you is which one are you actually after?

If you want to know at run time if you're under the CF, then check the Environment.OSVersion.Platform property to see if it's WinCE.

if(Environment.OSVersion.Platform == PlatformID.WinCE)
{
  // this is CF
}

At compile time it's not quite as straightforward. The default project Wizards add the compilation Symbols "PocketPC" for PPC/WinMo projects and "WindowsCE" for WinCE projects so you can do something like this:

#if WindowsCE || PocketPC
// this is CF
#endif

But there's nothing to say that a developer can't delete that symbol (or add it on a desktop project).

ctacke