【问题标题】:How to define Preprocessor Directive Global in c#如何在 C# 中定义预处理器指令全局
【发布时间】:2013-10-16 06:47:53
【问题描述】:

我的问题是如何在一个地方为网站中的所有 C# 类定义 Preprocessor Directive Global。

【问题讨论】:

标签: c# jquery wcf


【解决方案1】:

我认为没有办法创建全局#define。

如果您需要所有源代码文件都知道#define,则必须为解决方案中的每个项目/程序集创建一个。

【讨论】:

    【解决方案2】:

    我能找到类似的问题: Preprocessor directives across different files in C#

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DefineConstants>TRACE;DEBUG;LINQ</DefineConstants>
      </PropertyGroup>
    </Project>
    

    【讨论】:

      【解决方案3】:

      这在 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" />
      </compilers>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-07
        • 1970-01-01
        • 2012-02-21
        • 1970-01-01
        相关资源
        最近更新 更多