how to disable #if DEBUG in C# at Win 7 visual studio 2012

后端 未结 3 1050
慢半拍i
慢半拍i 2021-01-23 10:41

I am working on C# in Win 7 visual studio 2012.

I have #if DEBUG and I want to disable them. But, when I run C# in Visual Studio with \"start without debug

相关标签:
3条回答
  • 2021-01-23 10:49

    I assume you're already building against the "Release" built profile so I'll explain how to unset the DEBUG constant for release.

    Right-click on the project and in the Build section remove flag from "Define DEBUG constant". This flag should be removed only for the "Release" built profile and set for the "Debug" built profile.

    When you choose "Start without debug" you are not telling to built for release, but just to not attach the debugger to the process.

    Those are 3 different but inter-related things: built profile (Debug/Release), starting with or without debugger attached to the process and setting/unsetting the "Define DEBUG/TRACE constant".

    0 讨论(0)
  • 2021-01-23 10:58

    "Start without debugging" only means that VS will not attach the debugger to the running process; it doesn't change anything else. You're probably running using the Debug configuration - if you want to compile in Release, you should choose Release from the dropdown in the toolbar, where you should currently see a dropdown set to Debug.

    Visual Studio creates these configurations for your project to start, which control what preprocessor flags are set to, as well as a bunch of other configuration (how much optimization to use, etc.). You can edit them if you want, or even create new ones.

    0 讨论(0)
  • 2021-01-23 11:03

    Change your build configuration from Debug to Release.

    0 讨论(0)
提交回复
热议问题