There are some classes (of the .NET framework 3.5) that contain some methods that are supported in .NET Compact Framework, and some methods that are not supported. There are also some classes that does not exists for the .NET Compact Framework.
For example for the System.IO.File
class, the File.Create
function is supported by .NET Compact Framework, but the File.Encrypt
function is not.
Another example: the System.IO.File
class is supported by .NET Compact Framework, but the System.Diagnostic.StackTrace
is not.
I need to tell to the compiler something like this:
#ifdef COMPACT_FRAMEWORK // I'm compiling this from a smart device project
MyEncryptMethod("filename");
#else // I'm compiling this from a desktop project
File.Encrypt("filename");
#endif
How can I do?
(The specific version is Windows Mobile 6.1 Professional).
Just to add, since you are showing windows-mobile and windows-mobile-6, you should change your #define
constraint to PocketPC
instead of COMPACT_FRAMEWORK
.
#ifdef PocketPC // PocketPC is what the WM SDK uses
MyEncryptMethod("filename");
#else // I'm compiling this from a desktop project
File.Encrypt("filename");
#endif
Update:
Nick: What yms said. :) When building a project using one of the Smart Device projects, Visual Studio automatically add the conditional compilation symbol PocketPC
to the project.
From within VS2008's Main Menu, click Project and select your project's Properties at the bottom.
On your project's Properties page, go to the Build tab, and there you will see where PocketPC
is already defined for you.