F#断点仅在引发异常后才起作用

时间:2019-08-14 12:25:00

标签: visual-studio debugging visual-studio-code f# breakpoints

我尝试使用F#、. Net-Core 3,Ionide和Visual Studio Code创建一个ASP.Net网站,但是,当我尝试在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 个答案:

答案 0 :(得分:1)

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

  1. ASP.Net项目(F#)
  2. 迁移和DbContext项目(C#)
  3. 单元测试项目(F#)
  4. DbContext ASP.Net共享对象项目(F#)

我通过保留“迁移项目”但将DbContext移到ASP.Net项目中解决了该问题。因此,我将其更改为另一种方式,而不是从Migrations到ASP.Net项目的引用。这也使我可以将共享库移动到ASP.Net项目并删除共享库项目。 这就是后来的样子

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

尽管我不是为了解决这个问题而做的,但它是作为副作用解决的。 我希望这会对其他遇到相同或相似问题的人有所帮助。