简体   繁体   English

如何在Visual Studio 2010中更快地调试ASP.NET应用程序

[英]How can I debug asp.net applications more quickly in Visual Studio 2010

I am getting pretty frustrated by debugging, but maybe I am just doing it wrong. 我对调试感到非常沮丧,但是也许我做错了。

When I am actively developing it is extremely cumbersome to write some code, fire up the debugger to test said code, wait a minute for the debugger to start, look at the page in the browser, stop the debugger, edit the code, rinse, lather, repeat. 在我积极进行开发时,编写一些代码非常麻烦,启动调试器以测试所述代码,等待一分钟以等待调试器启动,在浏览器中查看页面,停止调试器,编辑代码,冲洗,泡沫,重复。

I can get around that by using CTRL-F5 and CTRL-SHIFT-B during development but I lose all the benefits of the debugger. 我可以通过在开发过程中使用CTRL-F5和CTRL-SHIFT-B来解决此问题,但是我失去了调试器的所有好处。

Is there a better way to use the debugger, or something else I can do to get quick rebuilds and use of the debugger? 有没有使用调试器的更好方法,或者我可以做其他一些事情来快速重建和使用调试器?

Thanks, 谢谢,

Kyle 凯尔

PS I/we do write unit tests, but you also need to test your app in the browser so please no "you shouldn't have this problem if your unit tests were written properly." PS I /我们确实编写了单元测试,但是您还需要在浏览器中测试您的应用程序,因此请不要“如果单元测试编写正确,就不会出现此问题”。 comments ;) 评论 ;)

Update 更新资料

Thanks for the "get a better machine" suggestions. 感谢您提供“获得更好的机器”的建议。 Not much I can do there. 我在那里没什么可做的。 Loads of RAM and an Intel SSD. RAM和Intel SSD的负载。 I shouldn't need more than a $2500 machine to code a web app. 我不应该需要超过2500美元的机器来编写Web应用程序。

You should take a look at this post (tweeted by Scott Guthrie): 您应该看一下这篇文章(由Scott Guthrie发推):

Slash your ASP.NET compile/load time without any hard work http://blog.lavablast.com/post/2010/12/01/Slash-your-ASPNET-compileload-time.aspx 大幅减少ASP.NET的编译/加载时间,无需任何辛苦工作 http://blog.lavablast.com/post/2010/12/01/Slash-your-ASPNET-compileload-time.aspx

Summary 摘要

  1. Get better hardware (Big impact) 获得更好的硬件(影响很大)
  2. Store your temporary IIS files on your fastest disk or a RAM disk eg <compilation ... tempDirectory="q:\\temp\\iistemp\\"> ... </compilation> 将临时IIS文件存储在最快的磁盘或RAM磁盘上,例如<compilation ... tempDirectory="q:\\temp\\iistemp\\"> ... </compilation>
  3. Restructure your projects 重组项目
    • Selectively build the necessary projects 有选择地建立必要的项目
  4. Review a few magical settings (Most impact) 查看一些神奇的设置(最具影响力)

Debug fewer times: If you are stopping the debugger to change values or test different scenarios then don't. 调试次数更少:如果要停止调试器以更改值或测试不同的场景,请不要这样做。 While debugging you can change the values of the variables using QuickWatch or the Immediate Window . 在调试时,您可以使用QuickWatchQuickWatch Immediate Window更改变量的值。

Make debugging less costly: Turning off batch will make your page load faster on the first time since it will no longer precompile all of your pages and user controls. 降低调试成本:关闭批处理将使您的页面首次加载速度更快,因为它将不再预编译所有页面和用户控件。 This is good for development if you are making changes quite often. 如果您经常进行更改,那么这对开发很有用。

<compilation ... batch="false"> ...</compilation>

获取SSD和大量的RAM。

Maybe what you need is not to debug faster, but to reduce the amount of times you need to debug. 也许您所需要的不是加快调试速度,而是减少调试时间。 Perhaps a more liberal Debug.* or trace logging approach would help. 也许更自由的Debug。*或跟踪日志记录方法会有所帮助。

@Kyle West - Well... there are a bunch of different ways you can go about it. @Kyle West-好吧...有很多不同的方法可以解决。 The approach that works best for me is to use the MS Enterprise Library Logging app block ( main site ) to log events to a rolling daily file. 最适合我的方法是使用MS Enterprise Library Logging应用程序块( 主站点 )将事件记录到滚动的每日文件中。 The log level can be ratcheted up (verbose detail) or down (exceptions only), just by editing the .config file. 只需编辑.config文件,就可以提高日志级别(详细信息)或降低日志级别(仅例外)。

There is a lot in the app block, so we created a wrapper around the logging calls so that we can more easily make the calls that matter. 应用程序块中有很多东西,因此我们在记录调用周围创建了一个包装器,以便我们可以更轻松地进行重要的调用。 For example, 例如,

DebugEvent.Log(String.Format("the value of _myVariable is {0}", _myVariable))
InfoEvent.Log("Reached the entry to the gatesOfHell method")
ExceptionEvent.Log(ex)

The nice thing about EL is you can change the config without having to change code. EL的好处是您无需更改代码即可更改配置。 So if you want to log to the event log or even email, its just a few lines of configuration. 因此,如果您想登录事件日志甚至是电子邮件,只需几行配置即可。

You can also substitute any other logger (log4Net, etc), or use the built in Debug or Trace in a way that is useful for you. 您还可以替换任何其他记录器(log4Net等),或以对您有用的方式使用内置的DebugTrace

The statement "Really I just want to see any exceptions that don't buddle up the UI." 语句“真的,我只想看到不会使UI混乱的任何异常。” is a bit worrisome, and implies that exception swallowing or some similar poor practice is happening. 有点令人担忧,并表示正在吞下异常或类似的不良行为。 (Thats a whole other bucket of roosters , and may be the reason why you have to debug so much). (这就是另外一堆公鸡 ,这可能是您必须进行大量调试的原因)。

Well, there are tools like Watin , which allow you to script browser interaction, but I don't think that's really what you want. 好吧,有诸如Watin之类的工具,可让您编写脚本与浏览器交互,但是我认为这并不是您真正想要的。

I guess the answer here is "Get a faster machine"... 我猜这里的答案是“获得更快的机器” ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有多个同时请求时如何在Visual Studio中更轻松地调试ASP.NET应用程序 - How to more easily debug ASP.NET applications in Visual Studio when there are multiple simultaneous requests ASP.NET Core Visual Studio 2015虚拟应用程序调试 - ASP.NET Core Visual Studio 2015 Virtual applications debug Visual Studio 2010和2012 ASP.Net调试和布局问题 - Visual Studio 2010 & 2012 ASP.Net debug & layout issues Visual Studio 2010中的ASP.NET SqlDataSource调试 - ASP.NET SqlDataSource Debug in Visual Studio 2010 如何使用Visual Studio 2010 asp.net设计视图绝对定位控件? - How can I position controls absolutely using the Visual Studio 2010 asp.net design view? 在ASP.NET中运行主项目时(使用Visual Studio(2010))如何调试工作目录* .aspx.cs文件? - How can I debug a working directory *.aspx.cs file when running the main project in ASP.NET (using Visual Studio (2010))? 如何避免从Visual Studio以调试模式发布ASP.NET应用程序? - How to avoid publishing ASP.NET applications in debug mode from Visual Studio? 如何确定ASP.NET网站是通过Visual Studio“正常”运行还是在“调试”状态运行? - How can I identify whether an ASP.NET site is being run “normally” or in “debug” via Visual Studio? 你可以在ASP.NET 4和Visual Studio 2010中使用HTML 5吗? - Can you use HTML 5 with ASP.NET 4 and Visual Studio 2010? Visual Studio 2010(最终版本):ASP.NET Web服务-调试断点未命中。 无法调试 - Visual Studio 2010 (Ultimate): ASP.NET Web Service - Debug Breakpoint does not hit. Not able to Debug
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM