Visual Studio Debugger没有进入.NET框架源代码

时间:2016-06-04 16:27:26

标签: c# .net visual-studio visual-studio-2015 visual-studio-debugging

我正在进行这个简单的异步调用。我想跟随调用DownloadDataTaskAsync方法并逐步进入Microsoft .NET框架源代码。

using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace WhereIsTheTaskSchedulerHere
{
    class Program
    {
        static void Main(string[] args)
        {
            var task = GetData("http://sathyaish.net");
            var buffer = task.Result;

            var data = Encoding.ASCII.GetString(buffer);

            Console.WriteLine(data);
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }

        async static Task<byte[]> GetData(string url)
        {
            var client = new WebClient();
            var data = await client.DownloadDataTaskAsync(url);
            return data;
        }
    }
}

我在Reflector中跟踪调用,直到代码调用System.Net.WebClient.DownloadBits方法为止。如果调用是异步执行的,则此方法通过调用BeginGetResponse类上的异步编程模型(APM)方法System.Net.WebRequest来进一步调度线程池线程上的工作。

以下是Reflector的DownloadBits方法的代码。

private byte[] DownloadBits(WebRequest request, Stream writeStream, CompletionDelegate completionDelegate, AsyncOperation asyncOp)
{
    WebResponse response = null;
    DownloadBitsState state = new DownloadBitsState(request, writeStream, completionDelegate, asyncOp, this.m_Progress, this);
    if (state.Async)
    {
        request.BeginGetResponse(new AsyncCallback(WebClient.DownloadBitsResponseCallback), state);
        return null;
    }
    response = this.m_WebResponse = this.GetWebResponse(request);
    int bytesRetrieved = state.SetResponse(response);
    while (!state.RetrieveBytes(ref bytesRetrieved))
    {
    }
    state.Close();
    return state.InnerBuffer;
}

因此,我在Visual Studio中设置了两个断点:

1)一个Sytem.Net.WebClient.DownloadBits方法;和另一个

enter image description here

2)在System.Net.WebRequest.BeginGetResponse方法上。

enter image description here

enter image description here

我仔细检查了以下内容。

1)我在 Visual Studio工具 - &gt;中配置了调试设置。选项对话框正确允许调试器逐步执行.NET框架源。

enter image description here

2)我已经启用了将调试符号下载和缓存到适当的位置。

enter image description here

3)我仔细检查了位置,发现我的代码引用的所有程序集都有Debug符号,特别是System.dll有我的断点设置的方法。

enter image description here

然而,当我在调试时运行代码时,它抱怨它无法找到System.dll的调试符号。因此,我单击了“加载”按钮,让它在运行时从Microsoft Symbol Server下载它们。

enter image description here

即便如此,虽然它确实在DownloadBits方法中突破,正如我从调用堆栈窗口中看到的那样,以及它在输出窗口中打印的消息我在设置断点时要求它打印,它没有显示或进入该方法的来源。

enter image description here

我右键单击调用堆栈窗口DownloadBits方法的堆栈框架,点击加载符号菜单项,但它不是&# 39;那里。因此,转到源代码菜单项也被禁用。

enter image description here

我清除了缓存,让它重新下载所有程序集,但这也没有帮助。

我正在使用Visual Studio Community Edition 2015,我的程序是针对.NET框架的v4.5.2,我之前已经能够使用此设置多次进入.NET源程序集。

我失踪了什么?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用带有dotPeek的动态符号服务器。它将反编译程序集并充当普通的Symbol Server。

在dotPeek中设置符号服务器(工具 - &gt;符号服务器)。将符号服务器地址复制到剪贴板。

将此符号服务器添加到Visual Studio并删除另一个(或者只是禁用它)。

请注意,加载所有.NET程序集可能需要很长时间。您可以通过选择dotPeek中的Assemblies opened in the Assembly Explorer选项来调整它。

相关问题