0

在 Visual Studio 2008 中,我有一个在同一解决方案中的两个项目之间共享的类。

我添加了一些对“ImageConverter”类的调用,这些调用在 Full .Net 框架上可用,但在 Compact Framework 上不可用。

它仅用于完整的框架项目,并且编译得很好。但是当我编译 Compact Framework 项目时,它显然会出错,因为这个类不可用。

如果它是 Compact Framework 或 WinCE 目标项目,是否有办法让编译器跳过方法。

4

2 回答 2

2

You can use conditional compilation or preprocessor directives like

#if CE
 ....
#else
 ...
#endif

You can define a set of active directives in project properties, for each build configuration.

于 2013-04-15T13:20:27.300 回答
0

I found the solution to the problem.

In the project properties under the "Build" tab you have "Conditional compilation symbols". Add a symbol here eg. WindowsCE

Inside your code you can now use the #if #endif to group parts of code to be skipped.

Example.

#if !WindowsCE

    // Some WindowsCE unsupported code here. 

#endif

The compiler will now skip this section.

于 2013-04-15T13:20:46.237 回答