"浏览查找源和QUOT;在Visual Studio 2010 [英] "Browse To Find Source" in Visual Studio 2010

查看:222
本文介绍了"浏览查找源和QUOT;在Visual Studio 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当是浏览查找源,在Visual Studio 2010中启用? (见下文)





另外,我想拥有它启用,这样我可以从浏览的文件:// referencesource .microsoft.com /> http://referencesource.microsoft.com/



由于微软并不总是释放这将是有益的<一个HREF =htt​​p://en.wikipedia.org/wiki/Program_database>在同一时间与他们的最新补丁PDB /源代码。所以,如果我想一步,例如成日期时间,我真的不关心不涉及日期时间最新的补丁。我只是想浏览它的代码是我从 http://referencesource.microsoft.com/ 下载。



一些调查,我发现后的 dia2dump 的是查看PDB文件内容的有用工具。 (它在 C:\Program文件(x86)\Microsoft的Visual Studio 10.0\DIA SDK\Samples\DIA2Dump\



它看起来就像当我看不到源代码类似的DateTime,使用.NET Framework步,实际上是一个 mscorlib.pdb 文件被下载。



但如果你看看里面用的 dia2dump 的它不包含源文件的映射。换句话说没用,因为即使你可以浏览到像我最初的想法的源代码,这是行不通的,因为没有源文件映射和功能没有起始地址,并错过了很多东西:(



我觉得这里的解决方案是使用 .net反射临支持或保持虚拟机在手,与具有源代码,然后禁用更新架构的版本。


解决方案

简介



当你从Visual Studio做一个构建,通常情况下,你也可以得到一个 PDB 除了你的可执行文件文件,你可以看到在 .. bin\Debug .. bin\Release <这个文件/ code>目录
本PDB文件保存映射到源代码行和汇编可执行代码。此外,从构建做存储内的源代码文件的原始位置PDB文件。
这意味着,如果你建立一个类库其中有位于单个文件G:\ClassLibrary\Class1.cs ,这条道路将被存放在里面 ClassLibrary.pdb
从所有这一切要记住最重要的是,没有一个PDB文件,它是不可能做到的源代码步调试。



现实生活中的场景



因此,假设我做了我的构建驱动 G于:\ClassLibrary1 ,一类库



我给你一个 ClassLibrary.dll ClassLibrary.pdb 文件或通过从源头控制检查出来得到它们。



您引用 ClassLibrary.dll 中。您的项目,您使用一个类从库



如果您现在尝试从库步入类代码将发生以下情况:



Visual Studio中尝试定位ClassLibrary.pdb文件的在几个地点




  • 1.1如果它没有找到它,你就会得到一个浏览查找源禁用
    页面。请记住,你不能没有一个有效的PDB文件调试。


  • 1.2如果它发现一个PDB文件,它看起来PDB文件里面看到你试图调试的Class1.cs 原本是从



    内置

       

    和期待您的电脑该文件上。


  • 1.2.1如果它发现它,它步入代码自动完成。


  • 1.2。 2如果没有找到它,你就会得到如下对话框:






如果您按取消,您将与提出的:没有可用的源代码,您将拥有浏览查找源,在这种情况下启用。





为什么呢?因为你有一个有效的PDB文件,但Visual Studio中不可能或不知道,你有ClassLibrary1的源代码,您的计算机上,如果你甚至有您的计算机上。这就是为什么你得到了对话框 - >这样就可以指向Visual Studio中的源代码文件的确切位置。



最后说明



所以,你会做什么,当你得到一个浏览找到源禁用?



在Visual Studio中,打开菜单的调试 - > 窗口的 - > 调用堆栈



您右键单击顶部的通话STAK指令,请选择符号负载信息。它会告诉你哪里的Visual Studio一直试图找到有效的PDB文件的位置。




  • 1.A如果你只看到无法找到或打开PDB文件的消息放在一个有效的PDB文件在任何这些位置。 (您可能需要向右滚动才能看到这些消息)停止并重新开始调试。

  • 1.B如果你看到一个PDB不将图像匹配的消息就意味着以下。 Visual Studio中已经找到了PDB文件,但它是另一个版本。如果我建立ClassLibrary1.dll并把它送给你,然后我又建立它在不改变的一行代码,然后给你PDB,并在尝试
    调试 classLibrary1.dll 你会得到此消息。大会及其PDB文件必须完全来自同一个版本,否则你会得到这个消息。 1.C你看到一个符号加载的消息,但仍获得了

  • (此检查是利用把每一个你做一个内置的时间组装和PDB文件里面的一些独特的号码一样)浏览找到禁用。这意味着,PDB文件你不适合步调试。您尝试使用一些PDB文件不具有所有这些必要的步骤,在调试的信息。我想你可以从某处高级构建设置控制这一点,但我还没有尝试过,但因为我想有发生,每次我做一个生成有用的PDB文件。如果你尝试调试 .NET框架本身的源代码,微软并没有把可用这种情况经常发生PDB文件的源代码,而是微软已经把不能被用于步骤-在调试一些PDB文件。这种情况多比你想象的,因为经常让微软更新(补丁)到.NET Framework源代码。这些更新默默通过的Windows Update安装到您的计算机,你感到吃惊的是昨天看到你可以调试的.NET Framework源代码今天你不能。它通常需要一些时间,直到他们把一个有效的PDB文件最新的验证码。在这种情况下,你可以使用 .net反射临步调试能力,或者具有.NET framework版本的虚拟机有可用的PDB文件,并在该计算机上禁用Windows更新。


When is "Browse To Find source" enabled in Visual Studio 2010? (see below)

In addition, I want to have it enabled so that I could browse to already-downloaded source code files from http://referencesource.microsoft.com/.

This would be useful since Microsoft doesn't always release PDB/source code at the same time with their latest patches. So if I want to step for example into DateTime, I really don't care about the latest patches which didn't involve DateTime. I just want to browse to its code which I downloaded from http://referencesource.microsoft.com/.

After some investigations I found dia2dump which is a useful tool to view PDB file contents. (It's in C:\Program Files (x86)\Microsoft Visual Studio 10.0\DIA SDK\Samples\DIA2Dump\)

It looks like when I can't see source code for something like DateTime, using .NET Framework stepping, a mscorlib.pdb file actually gets downloaded.

But if you look inside it with dia2dump it doesn't contain source file mappings. In other words useless, because even if you could browse to the source code like my initial idea, it wouldn't work because there are no source file mappings and no start addresses of the functions, and a lot of stuff missing :(

I think the solutions here are to use .NET Reflector Pro for or keep a virtual machine at hand, with releases of the framework which have source code and then disable updates.

解决方案

Introduction

Whenever you do a build from Visual Studio, normally, you also get a PDB file besides your executable file. You can see this file in the ..bin\Debug or ..bin\Release directory. This PDB file keeps a mapping to your source code lines and executable code in your assembly. Also, the original locations of the source code files from which a build was done is stored inside a PDB file. This means that if you build a class library which had a single file located at G:\ClassLibrary\Class1.cs, this path will be stored inside ClassLibrary.pdb. What is important to remember from all this is that without a PDB file it is impossible to do source code step-in debugging.

Real-life scenario

So, suppose I do a build on my drive G:\ClassLibrary1, for a class library.

I give you a ClassLibrary.dll and a ClassLibrary.pdb file, or you get them by checking them out from source control.

You reference the ClassLibrary.dll in your project and you use a class from the library.

If you now try to step into class code from the library the following will happen:

Visual Studio tries to locate a ClassLibrary.pdb file in a couple of locations

  • 1.1 If it doesn't find it, you get a "Browse to find source" disabled page. Remember, you can't debug without a valid PDB file.

  • 1.2 If it does find a PDB file, it looks inside the PDB file and sees that you are trying to debug Class1.cs which was originally built from

    G:\ClassLibrary1\Class1.cs
    

    and looks on your computer for that file.

  • 1.2.1 If it finds it, it steps into the code automatically.

  • 1.2.2 If it doesn't find it, you get the following dialog:

If you press Cancel, you will be presented with the: "No source available" and you will have "Browse to find source" enabled in this case.

Why? Because you have a valid PDB file, but Visual Studio can't possibly know where you have the source code for ClassLibrary1 on your computer or if you even have it on your computer. That's why you got the dialog -> so that you can point Visual Studio to the exact location of the source code file.

Final notes

So what will you do when you get a browse to find source disabled?

In Visual Studio, you open menu Debug -> Windows -> Call stack.

You right click on the top call stak instruction and you choose "Symbol Load Information". It will show you the locations where Visual Studio has tried to find a valid PDB file.

  • 1.a If you only see "Cannot find or open PDB file" messages put a valid PDB file at any of these locations. (You might have to scroll right to see the messages) Stop and start debugging again.
  • 1.b If you see a "PDB does not match the image" message it means the following. Visual Studio has found a PDB file, but it is for another build. If I build ClassLibrary1.dll and give it to you, and then I build it again without changing a single line of code and then give you the PDB, and you try to debug classLibrary1.dll you will get this message. The assembly and its PDB file must be exactly from the same build, otherwise you will get this message. (This check is done using some unique number put inside the assembly and PDB file every time you do a built)
  • 1.c You see a "symbols loaded" message but still get a "Browse to find" disabled. It means that the PDB file you have is not good for step-in debugging. Some PDB files you try to use don't have all the information in them necessary for step-in debugging. I think you can control this from somewhere in the advanced build settings, but I haven't tried it though, because I want to have usable PDB files generated everytime I do a build. This situation often happens if you try to debug the source code of the .NET framework itself and Microsoft hasn't put usable PDB files for the source code, but instead Microsoft has put some PDB files which can't be used for step-in debug. This happens more often than you think, because often Microsoft makes updates (patches) to the .NET Framework source code. These updates silently install onto your computer via Windows Update, and you are surprised to see that yesterday you could debug .NET Framework source code and today you can't. It usually takes some time until they put a valid PDB file for the latest code. In this case you can use .NET Reflector Pro step-debug ability or a virtual machine which has a .NET framework version with usable PDB files and disable Windows Update on that machine.

这篇关于&QUOT;浏览查找源和QUOT;在Visual Studio 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆