Redline
Redline

Reputation: 581

F# Breakpoints only work after a an exception is thrown

I tried to create an ASP.Net website using F#, .Net-Core 3, Ionide, and Visual Studio Code however, when I tried to set a breakpoint in an F# file it didn't get hit.

But when I put an

assert false

In front of my breakpoint, I get the exception, and the breakpoint gets hit afterward.

I have also tried the same in Visual Studio where the assert correctly breaks, but when continuing, it doesn't hit the breakpoint, even though VS Code does.

In VS Code, this doesn't work:

let x = 4 // <- Breakpoint

But this does:

assert false
let x = 4 // <- Breakpoint

I also get this warning when starting regardless of whether I add the assert or not.

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.

What could be the cause, and how could I fix it?

Upvotes: 3

Views: 162

Answers (1)

Redline
Redline

Reputation: 581

In the end, the problem was the complex inter-project dependencies I had.

  1. ASP.Net Project (F#)
  2. Migration and DbContext Project (C#)
  3. Unit-Test Project (F#)
  4. DbContext ASP.Net shared objects Project (F#)

I solved the problem by keeping the Migration Project but moving the DbContext into the ASP.Net Project. So instead of a reference from the Migrations to the ASP.Net Project, I changed it to the other way around. That also allowed me to move the shared objects to the ASP.Net project and delete the Shared Object Project. So this is what it looked like afterward

  1. ASP.Net and DbContext Project (F#)
  2. Migrations Project (C#)
  3. Unit-Test Project (F#)

Although I didn't do it to solve this problem, it solved it as a side-effect. I hope this will help someone else when they experience the same or similar problem.

Upvotes: 1

Related Questions