[英]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.