如何在c#中定义预处理器指令Global。 [英] How to define Preprocessor Directive Global in c#.

查看:130
本文介绍了如何在c#中定义预处理器指令Global。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi.My问题是如何在网站上的所有C#类的一个地方定义预处理器指令全局。

解决方案

它被定义为命令行参数编译器。从C#编译器CSC.EXE文档中可以看到,您可以使用命令行参数 / define

http://msdn.microsoft.com/en-us/library/vstudio/0feaad6z.aspx [< a href =http://msdn.microsoft.com/en-us/library/vstudio/0feaad6z.aspxtarget =_ blanktitle =New Window> ^ ],

http://msdn.microsoft.com/en-us/library/vstudio/78f4aasd .aspx [ ^ ]。



在MSBuild项目中,这是根据配置和平台属性在属性组中定义的

 <   DefineConstants  >  TRACE; DEBUG; SomeCustomConditionalCompilationSymbol <   / DefineConstants  >  





此功能的GUI前端界面取决于特定的IDE。在Visual Studio中,这是在项目属性页面,构建选项卡,条件编译S y mbols字段中完成的。



-SA


这在webconfig中适用于我:

 <   system.codedom  >  
< span class =code-keyword>< 编译器 >
< 编译器 >
language =c#; cs; csharpextension =。cs
compilerOptions =/ d:custompreprocessor
type =Microsoft.CSharp.CSharpCodeProvider,
System,Version = 2.0 .0.0,Culture = neutral,
PublicKeyToken = b77a5c561934e089/>
< / compiler > < / compilers > < / system.codedom >


Hi.My Question is how to define Preprocessor Directive Global at one place for all C# classes in website.

解决方案

It is defined as a command-line argument of a compiler. As you can see from the C# compiler CSC.EXE documentation, you can use the command-line argument /define:
http://msdn.microsoft.com/en-us/library/vstudio/0feaad6z.aspx[^],
http://msdn.microsoft.com/en-us/library/vstudio/78f4aasd.aspx[^].

In the MSBuild projects, this is defined in a property group, per Configuration and Platform properties, in

<DefineConstants>TRACE;DEBUG;SomeCustomConditionalCompilationSymbol</DefineConstants>



The GUI front-end interface to this feature depends on particular IDE. In Visual Studio, this is done on the project Properties page, the tab "Build", int the field "Conditional Compilation Symbols".

—SA


This works for me in webconfig:

<system.codedom>
<compilers>
  <compiler>
    language="c#;cs;csharp" extension=".cs"
    compilerOptions="/d:custompreprocessor"
    type="Microsoft.CSharp.CSharpCodeProvider, 
    System, Version=2.0.0.0, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089" />
</compiler></compilers></system.codedom>


这篇关于如何在c#中定义预处理器指令Global。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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