简体   繁体   中英

Retargeting .NET Core app to net462 misses breakpoints

I have a really strange problem. If I create a .NET Core console app and change the target framework to .NET 4.6.2, I get the typical "your breakpoint will not currently be hit" warning, and indeed breakpoints are never hit. So basically:

  1. Create a Console App (.NET Core) using VS2017.
  2. Add a breakpoint somewhere.
  3. Debug it. The breakpoint is hit.
  4. Change the <TargetFramework> from netcoreapp2.0 to net462 in the .csproj .
  5. Debug it (with breakpoint still there). The breakpoint is not hit.

I can consistently reproduce this on my machine, but a colleague of mine is following the same steps and not getting this on his machine.

I've tried all sorts of suggestions on Stack Overflow for dealing with typical "breakpoint will not be hit" scenarios, restarted VS, re-cloned the repo from scratch, restarted the whole machine, banged my head against the wall, and nothing worked.

So, I seem to have a problem specifically when retargeting an app, but it's strange that it didn't happen on a colleague's machine. Any idea what could be my problem?

I had the exact same problem with net471 and you can solve it by targeting both frameworks: core framework and full .net framework in csproj file.

After that, the breakpoint is hit again and you can use the full .net framework and core .net packages. If your project allows targeting multiple frameworks, this should help.

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp2.0; net471</TargetFrameworks>
  </PropertyGroup>

I found the answer that solves a problem without targeting both frameworks: https://stackoverflow.com/a/18738954/5532339

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM