#If DEBUG is ignored (VB.net or C#)

前端 未结 8 1052
青春惊慌失措
青春惊慌失措 2021-02-05 13:33

I have several of these in my code which have been working fine so far:

#If DEBUG Then    
   ... some code here       
#End If     

Now, i am

8条回答
  •  旧巷少年郎
    2021-02-05 14:01

    Had a similar problem where "DEBUG" was never true. Tried by doing an uncheck and check of the "Define DEBUG constant" checkbox and rebuilding everytime but that did not work.

    My solution was to define "DEBUG" manually in the "Conditional compilation symbols" textbox for the Debug configuration. When rebuilding, Visual Studio 2019 automatically removed the DEBUG symbol from the textbox (because this indeed should not be there) and from then on it worked again. When i switched from Debug to Release the correct lines got greyed out. This seems to be a possible bug in VS 2019 (16.4.5)?

提交回复
热议问题