如何在调试时让Visual Studio使用嵌入式源代码? [英] How can I get Visual Studio to use Embedded Source code whilst debugging?

查看:327
本文介绍了如何在调试时让Visual Studio使用嵌入式源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用csproj文件中的< EmbedAllSources> 元素将C#源代码嵌入到可移植的PDB文件中,并且使用以下命令将pdb嵌入到程序集中< DebugType>嵌入式< DebugType> ,如



根据Visual Studio 15.5的发行说明,调试器应该能够在调试过程中使用以下文件:





在讨论中搜寻时,ctaggart发表了评论



有人能成功使它工作吗?如果是这样,您能告诉我我在做什么错吗?

解决方案

最简单的方法是:



Debug-> Windows->模块



在此列表中,您应该能够找到您的程序集(dll / exe)。



右键单击它->加载符号



它将要求从何处加载符号。



导航到匹配的.pdb文件所在的目录。



它应该自动加载。踏入此引用的程序集中或在该程序集中有未捕获的错误应触发该代码的中断,或要求您导航到与引发该错误的文件相对应的代码文件。



在我们的过程中,通常必须导航到nuget缓存以找到已安装的nuget软件包的pdb。 (%UserProfile%/ nuget / packages / YourPackage / VersionNumber /../..)



我们还打包了使用这些软件包在源文件中导航,并导航到 / nuget / packages .cs 文件,不过,任何对应的.cs 文件应允许其加载。


I have embedded the C# source code into a portable PDB file using the <EmbedAllSources> element in the csproj file, and I have embedded the pdb into the assembly using the <DebugType>embedded<DebugType> as described in Embedding C# sources in PDB with new csproj

My assembly looks like this:

<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>    
    <EmbedAllSources>true</EmbedAllSources>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>embedded</DebugType>   
</PropertyGroup>

I can confirm that the pdb is type portable, and contains my source code:

According to the release notes for Visual Studio 15.5 the debugger should be able to use these files during debugging:

https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes-v15.5#EmbeddedSource

I'm using Visual Studio 2017 (version number 15.8.8)

However, when I F11 into the code from my assembly it asks for the sourcecode:

Whilst googling around there's a comment from ctaggart in the discussion https://github.com/ctaggart/SourceLink/issues/192 which says running sourcelink print-urls will print "embed" but mine doesn't, perhaps this is a hint:

Has anyone got this to work successfully? If so can you tell what I'm doing wrong?

解决方案

Easiest way is to go to:

Debug -> Windows -> Modules

Inside this list, you should be able to find your assembly (dll/exe).

Right click it -> Load Symbols

It will ask for where to load the symbols from.

Navigate to the directory where your matching .pdb file is.

It should auto load. Stepping into, or having uncaught errors in this referenced assembly should trigger a break in that code, or ask you to navigate to the code file that corresponds to the file that threw the error.

In our process, we generally have to navigate to the nuget cache to find the pdbs for our installed nuget packages. (%UserProfile%/nuget/packages/YourPackage/VersionNumber/../..)

We also package up the source with those packages and navigate to those /nuget/packages .cs files as well, though, any corresponding .cs file should allow it to load.

这篇关于如何在调试时让Visual Studio使用嵌入式源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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