如何只在ASP.NET调试模式中执行code [英] How to execute code only in debug mode in ASP.NET
本文介绍了如何只在ASP.NET调试模式中执行code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ASP.NET Web应用程序,我有一些code,我想只有在调试版本中执行。如何做到这一点?
解决方案
#如果DEBUG
您code
#万一
您还可以添加<一个href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute.aspx\">ConditionalAttribute要方法是当你在调试模式下建立它仅被执行:
[条件(DEBUG)]
无效的someMethod()
{
}
I have an ASP.NET web application and I have some code that I want to execute only in the debug version. How to do this?
解决方案
#if DEBUG
your code
#endif
You could also add ConditionalAttribute to method that is to be executed only when you build it in debug mode:
[Conditional("DEBUG")]
void SomeMethod()
{
}
这篇关于如何只在ASP.NET调试模式中执行code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文