如何在 Visual Studio 中调试这行代码?

发布于 2024-07-13 12:04:08 字数 623 浏览 6 评论 0原文

我在VS2008中有以下代码行。

    VirtualPathData virtualPathData = 
        RouteTable.Routes.GetVirtualPath(_viewContext.RequestContext, 
        "Home", 
        pageLinkValueDictionary);

我希望调试这个 GetVirtualpath(..) 方法..以查看它正在尝试执行的操作。

我假设我需要从 MS 符号服务器获取符号。

我所做的是

  • 关闭仅启用我的代码
  • 打开启用源服务器支持
  • 在调试时显示模块窗口(手动加载正确的模块) )

在调试模式下编译,在该行上放置一个断点并调试运行。 当我上线时,我从 MS Symbol 服务器 手动加载 System.Web.Routing(..)。 这是可行的(pdb是本地下载的),当我进入这一行时,我转到一些Dissassemler代码:(

任何人都可以看到我做错了什么吗?

I have the following line of code in VS2008.

    VirtualPathData virtualPathData = 
        RouteTable.Routes.GetVirtualPath(_viewContext.RequestContext, 
        "Home", 
        pageLinkValueDictionary);

I wish to debug this GetVirtualpath(..) method .. to see what it's trying to do.

I'm assuming I need to grab the symbols from the MS symbol server.

What I did was

  • Turn OFF Enable just my code
  • Turn ON Enable source server support
  • Show the Modules window when debugging (to manually load the correct module)

Compile in debug mode, put a breakpoint on that line about and debug-run. When I hit the line, I manually load in System.Web.Routing(..) from MS Symbol server. This works (the pdb is downloaded locally) and when i step INTO this line, I goto some Dissassemler code :(

Can anyone see what I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

南汐寒笙箫 2024-07-20 12:04:08

下载符号文件并不意味着源可用,pdb 也需要进行源索引。

来自 斯科特·格思里的公告

我们将首先提供来源
代码(带有源文件注释
包括)用于 .NET 基类
库(系统、System.IO、
系统.集合,
系统配置,
系统.线程,系统.Net,
系统.安全性,系统.运行时,
System.Text 等)、ASP.NET
(系统.Web)、Windows 窗体
(系统.Windows.Forms),ADO.NET
(System.Data)、XML (System.Xml) 和
WPF(系统.Windows)。 那时我们就会
几个月内添加更多库
领先(包括 WCF、工作流和
LINQ)。 源代码将是
根据 Microsoft 参考发布
许可证 (MS-RL)。

这里似乎不包括 System.Web.Routing。

但是,您可以下载 MVC 源,然后您应该能够使用针对该源下载的 pdb 。

That the symbols file is downloaded doesn't mean that sources are available for it, the pdb needs to be source indexed as well.

From Scott Guthrie's announcement:

We'll begin by offering the source
code (with source file comments
included) for the .NET Base Class
Libraries (System, System.IO,
System.Collections,
System.Configuration,
System.Threading, System.Net,
System.Security, System.Runtime,
System.Text, etc), ASP.NET
(System.Web), Windows Forms
(System.Windows.Forms), ADO.NET
(System.Data), XML (System.Xml), and
WPF (System.Windows). We'll then be
adding more libraries in the months
ahead (including WCF, Workflow, and
LINQ). The source code will be
released under the Microsoft Reference
License (MS-RL).

It seems System.Web.Routing isn't included here.

You can however download the MVC Source, then you should be able to use the pdbs you downloaded against that source.

弥枳 2024-07-20 12:04:08

我看到有人已经因为这么说而被修改了,但是......

似乎您无法获得正在发生的事情的源代码级别视图,但如果您确实需要关于为什么某些东西可能不起作用的答案(并且StackOverflow 无法提供帮助),使用 Reflector.NET 从已编译的程序集中获取 C# 代码(dll 或 exe)是一个不错的选择。 对于任何有经验的 .NET 开发人员来说,该工具都非常易于使用,并且可以提供有关正在发生的情况的一些非常好的见解。

我们中的许多人在 .NET 前沿工作需要使用它,因为通常没有其他快速方法,对于那些没有 MVP 或 Microsoft 端连接的人来说,它通常是获取“内幕故事”的唯一方法。

I saw someone get modded down already for saying this, but...

It does not seem that you can get a source-level view of what is going on, but if you really need an answer on why something might not be working (and StackOverflow cannot help), using Reflector.NET to get C# code from the compiled assembly (dll or exe) is a pretty good option. The tool is quite easy to use for any experienced .NET developer and can provide some very good insights into what is happening.

Many of us who work at the leading edge of .NET need to use it because there is often no other fast method, and for those without MVP or Microsoft-side connections, it is commonly the only way to get the 'inside story'.

终难遇 2024-07-20 12:04:08

我有点惊讶它为此下载了一个符号文件; 上次我查看时,只有框架的一小部分(主要是 2.0)的符号。 您现在对这段代码有疑问吗? 如果是这样,请发布异常/意外行为的详细信息。 如果您只是好奇,那么可以:阅读文档,或 b:也许有一个带有 reflector 的窥探器(警告:“< a href="http://en.wikipedia.org/wiki/IANAL" rel="nofollow noreferrer">IANAL")。

I'm a little surprised it downloaded a symbol file for that; last time I looked, there were only symbols for a small subset (mainly 2.0) of the framework. Are you having a problem with this code at the moment? If so, post details of the exception / unexpected behaviour. If you are simply curious, then either a: read the documentation, or b: perhaps have a snoop with reflector (caveat: "IANAL").

罪歌 2024-07-20 12:04:08

看起来您正在谈论 .NET,所以您看到的实际上是 IL 字节代码。 我认为 Microsoft 不会发布带有 .NET 源代码的符号,因此 VS 无法帮助您。

使用 .NET Reflector 检查函数的作用。

Looks like you're talking about .NET, so it's actually IL byte code you're seeing. I don't think Microsoft releases symbols with source code for .NET, so VS can't help you.

Use .NET Reflector to inspect what the function does.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文