简体   繁体   English

调试使用WinForms应用程序时不会击中.net核心库中的断点

[英]Breakpoints in .net core library will not be hit when debugging consuming WinForms app

I created a sample to reproduce my issue at work, and the problem is there. 我创建了一个示例来重现我在工作中遇到的问题,而问题就在那里。 I have a Solution with a WinForms project, targeting .NET framework 4.7, and a .NET Core library, targint .NET Core 2 (tried the 4.6.1 / .Net Standard 2.0 combination as well, same) 我有一个针对WinForms项目的解决方案,目标是.NET Framework 4.7,还有一个.NET Core库targint .NET Core 2(也尝试过4.6.1 / .Net Standard 2.0组合)

Form1.cs looks like: Form1.cs看起来像:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show(Helper.Method1(100).ToString());
    }
}

Library code: 库代码:

public static class Helper
{
    public static int Method1(int a)
    {
        a = a + 1;

        return a; //breakpoint here
    }

}

I can't have Visual Studio hit the breakpoint in Helper, from the .net core library (in neither one of the combinations - .net framework vs .net core NOR .net framework (4.6.1) vs .net standard (2.0)) 我无法让Visual Studio从.net核心库中找到Helper中的断点(在任何一种组合中-.net框架与.net核心NOR .net框架(4.6.1)与.net标准(2.0) )

What am I missing ? 我想念什么?

I found a Scott Hanselman's post on this , but, if I got him right, what is required is that the library does not taget a specific framework rather one of the .NET standards (and that the consuming project targeting framework complies with that standard). 在此找到了Scott Hanselman的帖子 ,但是,如果我说对了,那么所需要的是该库不标记特定框架而是.NET标准之一(并且使用目标项目的框架符合该标准)。 。 I seem to be doing that. 我似乎正在这样做。

To be able to hit breakpoints set within Visual Studio, it needs to have information files (for instance the .pdb files you see within the ./bin/Debug directory) that help Visual Studio to know where exceptions occur, gather information on variable values, and way more stuff. 为了能够达到在Visual Studio中设置的断点,它需要具有信息文件(例如,您在./bin/Debug目录中看到的.pdb文件),以帮助Visual Studio知道发生异常的位置,收集有关变量值的信息。 ,以及更多方式。

The amount of information that is generated in addition to the actual application/library files can be set accordingly here: Go to Project > Properties > Build > Advanced (button at bottom) > Debugging information. 除了实际的应用程序/库文件外,还可以在此处设置生成的信息量:转到“项目”>“属性”>“构建”>“高级”(底部按钮)>“调试信息”。

Note: this is not solution wide setting, it needs to be set for each project. 注意:这不是解决方案范围的设置,需要为每个项目进行设置。 For more information on what the selectable settings mean: Advanced Build Settings Dialog Box 有关可选设置的含义的更多信息,请参见: 高级构建设置对话框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调试ASP.Net应用程序-跳过行和断点​​未命中 - Debugging ASP.Net app - skipping lines and breakpoints not being hit 调试时未击中断点,Outlook Add in - Breakpoints are not hit when debugging, Outlook Add in 在Visual Studio中远程调试Azure Web应用程序时未达到断点 - Breakpoints not being hit when remote debugging Azure web app in Visual Studio .net core web api 500错误,无法命中断点 - .net core web api 500 error and can't hit breakpoints 在 .NET Core 应用程序中使用 LTTng 事件 - Consuming LTTng events in a .NET Core app C# Dll 如果 output 目录不是调用应用程序正在调用的位置,则调试断点未命中 - C# Dll debugging breakpoints not hit if output directory is not the location that the calling app is calling 在VS 2005中,调试调试版本时未达到断点是什么意思? - in VS 2005 what does it mean when breakpoints are not hit when debugging a Debug build? 将.NET Core应用重新定位为net462会错过断点 - Retargeting .NET Core app to net462 misses breakpoints 为什么在调试Silverlight应用程序时断点不起作用? - why breakpoints don't work when debugging Silverlight app? Blazor Webassembly 项目、ASP.NET Core 3.1 中不会出现断点, - Breakpoints won't hit in Blazor Webassembly project, ASP.NET Core 3.1,
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM