简体   繁体   English

如何在 Visual Studio 2019 中调试 .NET 5 WinForms 应用程序,该应用程序引用 .NET Framework 4.8 class 库

[英]Howto debug .NET 5 WinForms application that references .NET Framework 4.8 class library in Visual Studio 2019

I have test .NET 5 WinForms application that references .NET Framework 4.8 class library - Github link .我已经测试了 .NET 5 WinForms 应用程序,它引用了 .NET Framework 4.8 class 库 - ZE1ADBCBB92C622D30B3E619F9D0 链接

I suppose it's possible because of .NET Framework compatibility mode我想这是可能的,因为.NET 框架兼容模式

When I'm trying to debug a class library in Visual Studio 2019 16.8.4 (by starting my .NET 5 application) I get an error:当我尝试在Visual Studio 2019 16.8.4中调试 class 库时(通过启动我的 .NET 5 应用程序)出现错误:

The debugger was configured to use the Desktop CLR (.NET Framework) Managed debugger, but the target process loaded the CoreCLR (.NET Core) runtime.调试器配置为使用桌面 CLR (.NET Framework) 托管调试器,但目标进程加载了 CoreCLR (.NET Core) 运行时。 The debugger was configured to use the Desktop CLR (.NETFramework) Managed debugger, but the target process loaded the CoreCLR (.Net Core) runtime.调试器配置为使用 Desktop CLR (.NETFramework) 托管调试器,但目标进程加载了 CoreCLR (.Net Core) 运行时。 To debug this project, configure it to use the 'Managed (CoreCLR)' debugger.要调试此项目,请将其配置为使用“托管 (CoreCLR)”调试器。

在此处输入图像描述

Where can I find an option to use the 'Managed (CoreCLR)' debugger .在哪里可以找到使用“托管 (CoreCLR)”调试器的选项。

Thank you in advance.先感谢您。

UPDATE If I start debugging from .NET 5 application project - I can step into .NET Framework 4.8 class library.更新如果我从 .NET 5 应用程序项目开始调试 - 我可以进入 .NET Framework 4.8 class 库。 But I want to debug from class library project.但我想从 class 库项目中进行调试。

One useful function is to change your net framework project from non-sdk into new-sdk csproj format.一种有用的 function 是将您的网络框架项目从non-sdk更改为new-sdk csproj 格式。

1) create a net core class library project and then enter its csproj file and then change the targetframework into: 1)创建一个net core class库项目,然后进入其csproj文件,然后将targetframework改为:

<TargetFramework>net48</TargetFramework>

So you got a net framework4.8 project which is compatible with CoreCLR .所以你得到了一个与CoreCLR兼容的net framework4.8项目。

See this document .请参阅此文档

When you finish it, please move your non-sdk net framework4.8 files into the new one.完成后,请将您的非sdk net framework4.8 文件移动到新文件中。

2) use Attach to Process and it should has a execute program to run the code of the lib project. 2)使用附加到进程,它应该有一个执行程序来运行lib项目的代码。

You can check this issue to get the detailed steps, when you open Attach to Process and remember to choose Managed(.Net Core,NET5+) and that is the debugger.当您打开Attach to Process并记住选择Managed(.Net Core,NET5+)即调试器时,您可以查看此问题以获取详细步骤。

在此处输入图像描述

This is a similar issue about it .这是一个类似的问题

In fact , I recommend the solution one and solution two might have some small problems.其实我推荐方案一,方案二可能会有一些小问题。

暂无
暂无

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

相关问题 Visual Studio 2019 - 将 .NET 目标框架更改为 4.8 - Visual Studio 2019 - change .NET target framework to 4.8 .NET Framework 4.8 已安装但未在 Visual Studio 2019 社区中显示 - .NET Framework 4.8 is installed but not showing in Visual Studio 2019 community 在 Visual Studio 2019 / .NET Framework 4.8 中确定 C# 版本 - Determine C# version in Visual Studio 2019 / .NET Framework 4.8 Visual Studio 2019 应用程序需要 .NET 框架 - Visual Studio 2019 The application requires .NET framework 如何在 Visual Studio 2005 或 2019 中为 .NET Framework 2.0 编译一个简单的 WinForms C# 应用程序? - How do I compile a simple WinForms C# application for .NET Framework 2.0 in Visual Studio 2005 or 2019? 如何将所有解决方案项目 .Net framework 4.5.1 升级到 4.8 Visual Studio 2019 - How to upgrade all solution projects .Net framework 4.5.1 to 4.8 Visual Studio 2019 使用.Net Framework v4.8和Visual Studio 2019查询TFS 2015源代码存储库DateTime属性 - Querying TFS 2015 Source Code Repository DateTime Properties with .Net Framework v4.8 and Visual Studio 2019 为 .NET Core 类库项目选择框架版本 - Visual Studio 2019 - Select framework version for .NET Core Class Library project - Visual Studio 2019 Class 库(.NET 标准)模板在 Visual Studio 2019 中不起作用 - Class Library (.NET Standard) Template Not working in Visual Studio 2019 Visual Studio 2019 中的 .Net Standard 1.0 class 库 - .Net Standard 1.0 class library in Visual Studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM