简体   繁体   English

调试ASP.Net应用程序-跳过行和断点​​未命中

[英]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: 我怀疑有几个相关的问题:

  • Breakpoints inside the functions are ignored but if I put a breakpoint before that function is called and then f11 to step in I can debug the function as normal. 函数内部的断点将被忽略,但是如果我调用该函数之前放置一个断点,然后按f11进入,则可以正常调试该函数。
  • If I attach the debugger and then add a break point it will add it (although it will be ignored as above) as long as the code hasn't been executed. 如果我附加了调试器,然后添加一个断点,则只要未执行代码,它将添加它(尽管如上将被忽略)。 Once the function has been called if I try and add a break point visual studio gives an error "The following breakpoint cannot be set...The common language runtime was unable to set the break point. 如果我尝试添加断点,则调用该函数后,Visual Studio会显示错误消息“无法设置以下断点...公共语言运行库无法设置断点。
  • 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: 我已经尝试过的东西:

  • Cleaning solution 清洗液
  • Rebuilding solution 重建解决方案
  • Manually deleting all dlls and pdb files in bin folder 手动删除bin文件夹中的所有dll和pdb文件
  • Restarting visual studio 重新启动Visual Studio
  • Rebooting 重新启动
  • Ensuring 'Optimize Code' is disabled 确保禁用“优化代码”
  • Ensuring that multiple threads aren't calling the function at the same time 确保多个线程不会同时调用该函数
  • Modifying the code file and making sure it picks up the changes to make sure it is running the most current version. 修改代码文件并确保它吸收了所做的更改,以确保其运行最新版本。 It is. 它是。 (also opended the Debug > Windows > Modules and checked the timestamp on the pdb - it's up to date) (也打开了Debug> Windows> Modules并检查了pdb上的时间戳-它是最新的)
  • Deleting IIS copy of DLLs located at C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Temporary ASP.NET Files 删除位于C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\临时ASP.NET文件的DLL的IIS副本
  • Clearing Symbol Cache 清除符号缓存
  • Complete reinstall of VS2012 and all plugins (eg resharper) 完全重新安装VS2012和所有插件(例如resharper)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM