F# 断点仅在引发异常后才有效



我尝试使用 F# 创建一个 ASP.Net 网站,.Net-Core 3,Ionide和Visual Studio Code但是,当我尝试在F#文件中设置断点时,它没有命中。

但是当我放一个

assert false

在我的断点前面,我得到异常,之后断点被命中。

我也在Visual Studio中尝试过相同的方法,断言正确中断,但是在继续时,即使VS Code会命中断点,它也不会命中断点。

在 VS Code 中,这不起作用:

let x = 4 // <- Breakpoint

但这确实:

assert false
let x = 4 // <- Breakpoint

无论我是否添加断言,我在启动时也会收到此警告。

Breakpoint warning: No executable code of the debugger’s target code type is associated with this line.
Possible causes include: conditional compilation, compiler optimizations, or the target architecture of this line is not supported by the current debugger code type.

原因可能是什么,我该如何解决?

最后,问题是我拥有复杂的项目间依赖关系。

  1. ASP.Net 项目(F#(
  2. 迁移和数据库上下文项目(C#(
  3. 单元测试项目(F#(
  4. DbContext ASP.Net 共享对象项目(F#(

我通过保留迁移项目但将 DbContext 移动到 ASP.Net 项目中解决了这个问题。因此,我没有从迁移到 ASP.Net 项目的引用,而是将其更改为相反的方式。这也允许我将共享对象移动到 ASP.Net 项目并删除共享对象项目。 所以这就是后来的样子

  1. ASP.Net 和 DbContext 项目(F#(
  2. 迁移项目(C#(
  3. 单元测试项目(F#(

虽然我这样做不是为了解决这个问题,但它作为副作用解决了它。 我希望当其他人遇到相同或类似的问题时,这将帮助他们。

相关内容

最新更新