[英]Debugging ASP.Net app - skipping lines and breakpoints not being hit
I am experiencing a very strange issue while debugging an ASP.Net application. 在调试ASP.Net应用程序时遇到一个非常奇怪的问题。 It seems to happen to all functions inside a certain class. 似乎发生在某个类中的所有函数。 There are several issues which I suspect are all related: 我怀疑有几个相关的问题:
While debugging some of the lines seems to get skipped over completely. 在调试时,有些行似乎被完全跳过了。 For example consider the function below: 例如,考虑以下功能:
public GetCareersParametersByCriteriaResponse GetCareersParametersByCriteria(GetCareersParametersByCriteriaRequest request) { var response = new GetCareersParametersByCriteriaResponse { CareersParameters = new List<CareerParametersView>() }; var predicate = PredicateBuilder.True<CareerView>(); if (!request.IncludeExcludeTop20Careers) { predicate = predicate.And(c => !c.ExcludeTop20); } predicate = predicate.And(c => c.EducationMinimumLevel <= request.MinimumEducationLevel && c.EducationMaximumLevel >= request.MaximumEducationLevel); var careerIds = _careerLibrary.Careers.AsQueryable().Where(predicate).Select(c => c.CareerId).Distinct(); foreach (var careerId in careerIds) { response.CareersParameters.Add(_careerLibrary.CareerParametersLookup[careerId]); } response.IsSuccess = true; return response; }
It seems to skip assigning to 'predicate' and the value shows as null. 似乎跳过了分配给“谓词”的操作,该值显示为null。 However the line later that adds the education min / max still executes but the value of predicate remains null. 但是,添加教育最小值/最大值的行仍会执行,但谓词的值仍为空。 From there it skips straight into the foreach without assigning to careerIds and seemingly without calling move next on the iterator. 从那里,它直接跳转到 foreach中,而不分配给careerIds,而且似乎没有在迭代器上调用next。 As a result careerId is not assigned a value (so has 0) and throws an error because 0 is not a valid Id. 结果,没有为careerId分配值(因此为0),并且由于0不是有效的ID而引发错误。
Note: Even though 0 is an invalid id and results in a 'given key not present in the dictionary' exception being thrown, the function continues executing and does the return. 注意:即使0是无效的ID,并导致抛出“字典中不存在给定的键”异常,该函数仍继续执行并返回。 At that point the debugger disappears completely (doesn't return to calling function) and everything seems to lock (ie the page never loads etc) until I detach the debugger and it gives the yellow screen of death. 到那时,调试器完全消失(不返回调用函数),一切似乎都被锁定(即页面从不加载等),直到我拆开调试器,并给出黄色的死亡屏幕。
Thing I have already tried: 我已经尝试过的东西:
It seemed to start happening immediately after installing the VS2012 update 4 but I cannot find anything online regarding any problems like this after the update, and reinstalling VS did not help so this may be coincidence 在安装VS2012更新4之后,它似乎立即开始发生,但是在更新之后,我无法在网上找到任何有关此类问题的信息,并且重新安装VS并没有帮助,所以这可能是巧合
Update: After getting a message while debugging that the source code was different to the dll at C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Temporary ASP.NET Files...(ie IIS copy of the code) I thought I might be on to something. 更新:调试时收到一条消息,指出源代码与C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ Temporary ASP.NET Files ...(即代码的IIS副本)上的dll不同时,我以为我可能会做某事。 However after deleting those it still made no difference at all, so adding that to the list of things I've tried 但是,在删除这些内容之后,它仍然没有任何区别,因此将其添加到我尝试过的事情列表中
Update 2: Completely reinstalled VS2012 since I suspected the update might be at fault. 更新2:完全重新安装了VS2012,因为我怀疑更新可能有问题。 However still no joy, same strange behaviour 但是仍然没有喜悦,同样的奇怪行为
Update 3: After further investigation I seem to get the same strange problems for all classes inside the same project / assembly (other projects in the solution are fine) this suggests a project level setting somewhere. 更新3:经过进一步调查,我似乎在同一项目/程序集中的所有类上都遇到了相同的奇怪问题(解决方案中的其他项目都很好),这表明某个地方的项目级别设置。 Open to all suggestions :-) 接受所有建议:-)
Update 4: Tried Clearing Symbol Cache at Tools > Options > Debugging > Symbols 更新4:尝试在工具>选项>调试>符号中清除符号缓存
update 5: Tried reinstalling VS2012 from scratch - still no joy 更新5:尝试从头开始重新安装VS2012-仍然没有喜悦
最后,完全重新格式化并重新安装是解决问题的唯一方法
Try opening the Modules
window (Debug->Windows->Modules)
and have a look through the list of modules. 尝试打开“ Modules
窗口(Debug->Windows->Modules)
并浏览模块列表。 You should see DLL files relating to your project. 您应该看到与您的项目有关的DLL文件。 Now, the important thing is whether the Symbol Status
columns says Symbols Loaded
. 现在,重要的是“ Symbol Status
列是否显示Symbol Status
Symbols Loaded
。 If it does not, then have a look at the Path
column, check whether that looks correct. 如果不是,请查看“ Path
列,检查它是否正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.