条件编译 [英] Conditional compiling

查看:95
本文介绍了条件编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够支持多个版本的c#。编译器

是否定义了任何#defines,以便判断您是在编译.NET 1.1还是2.0?

I need to be able to support multiple versions of c#. Does the compiler
define any #defines so you can tell if you are compiling for.NET 1.1 or 2.0?

推荐答案

我很确定你有充分的理由,但我很好奇......为什么?

I''m sure that you have a good reason, but I''m curious... why?


我不这么认为。当它针对1.1或

2.0时它是一个不同的编译器,这就是VS 2005仅适用于2.0和2003 1.1的原因。

FWIW,你应该能够编译为1.1,如果需要,仍然可以通过.net 2.0加载你的

程序集。只需在你的2.0项目中使用你的1.1

组装和参考......应该可以正常工作。

I wouldn''t think so. Its a different compiler when targeting 1.1 or
2.0, which is why VS 2005 only works with 2.0 and 2003 1.1.

FWIW, you should be able to compile to 1.1, and still have your
assembly loaded by .net 2.0 if you need to. Just take your 1.1
assembly and reference in your 2.0 project... should work just fine.


我是不是100%肯定,但我认为如果您需要使用2.0 Framework和其他仅具有1.1

框架的系统来定位两个系统,您只需要坚持VS2003。


虽然我无法对此做出明确的声明,但我相信为1.1编译的代码

将在具有此功能的系统上运行只安装了2.0 Framework

。我们已经尝试过在这台机器上编写的代码

只有2.0而不是1.1,并且它运行正常,我们仍然在

VS2003。


当然,我们的代码没有运用

框架的所有功能,因此可能存在版本不兼容,但在此

newsgroup我只听说过一个。

I''m not 100% sure, but I would assume that if you need to target both
systems with the 2.0 Framework and other systems that have only the 1.1
Framework, you would simply stick to VS2003.

Although I can''t make a solid claim to this, I believe that code
compiled for 1.1 will run on systems that have only the 2.0 Framework
installed. We have tried code that we have written here on a machine
that has only 2.0, not 1.1, and it runs fine, and we are still on
VS2003.

Of course, our code does not exercise all of the capabilities of the
Framework, so there may be version incompatibilities, but in this
newsgroup I''ve heard of only one.


这篇关于条件编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆