如何在c#中定义预处理器指令Global。

编程入门 行业动态 更新时间:2024-10-23 01:53:48
本文介绍了如何在c#中定义预处理器指令Global。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

解决方案

它被定义为命令行参数编译器。从C#编译器CSC.EXE文档中可以看到,您可以使用命令行参数 / define : msdn.microsoft/en-us/library/vstudio/0feaad6z.aspx [ ^ ], msdn.microsoft/en-us/library/vstudio/78f4aasd .aspx [ ^ ]。 在MSBuild项目中,这是根据配置和平台属性在属性组中定义的

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

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

-SA

这在webconfig中适用于我:

< system.codedom > < 编译器 > < 编译器 > 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: msdn.microsoft/en-us/library/vstudio/0feaad6z.aspx[^], msdn.microsoft/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。

本文发布于:2023-11-14 00:43:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585754.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   定义   如何在   Global

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!