.NET source debugging on Windows 7

断了今生、忘了曾经 提交于 2019-12-11 00:55:09

问题


We are trying to debug through a SQL Server Compact issue on a Windows 7 Enterprise RTM (64-bit) desktop running the .NET Framework 3.5, SP1. The application is crashing consistently, and we are trying to set up .NET Framework debugging for Visual Studio 2008, SP1. Using the scattered resources around the Internet, we set the options:

  • Symbol Server = http://referencesource.microsoft.com/symbols
  • Menu Tools -> Options -> Debugging -> Just My code = Disabled
  • Menu Tools -> Options -> Debugging -> Enable .NET Framework Debugging = Enabled
  • Tools -> Options -> Debugging -> Enabled Source Server Support = Enabled

When we run the application, we are unable to step into the source and we still get the error

There is no source code at this location.

We do get the stack trace indicating that the SQL Server Compact symbols have loaded and when we click the details on the error dialog, we get a message indicating that the SQL Server Compact PDB file was loaded correctly.

I did find a blog post indicating that this is an issue with the symbols not being updated for Windows 7, yet, Visual Studio 2008 SP1 .NET Framework Source Debugging.

However, I cannot find anything official about this issue. Is there anything I'm missing? Is it true that Windows 7 symbols are being incorrect. If so, when will they be updated?

My Windows 7 build is 64-bit. We also just tested this same scenario on Windows Vista 64-bit and received the same problem and error. It says that it loaded the PDB, but it claims there is no source code at the location.


回答1:


My guess is that your DLL files are release build, and so the JIT compiler is optimising away some of the function calls (it often inlines small functions). That means that when the runtime tries to translate from the jitted code back to the PDB, it gets confused.

Try adding an .ini file to your application root; so if your app is prog.exe, add prog.ini with the following content;

[.NET Framework Debugging Control] 
GenerateTrackingInfo=1
AllowOptimize=0

This will stop the JIT compiler from optimising away the calls, and let your PDB files refer to the correct calls in your code. You'll need to restart the application, and because it's running without optimisations, it'll slow it down to DEBUG build levels, but you should be able to attach the debugger correctly.




回答2:


In the project build properties, there is an option to choose which architecture to run on - x86 or x64. You might try switching to x86 for debugging purposes; it may allow you to debug and find your problem.



来源:https://stackoverflow.com/questions/1428916/net-source-debugging-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!