InvalidOperationException in Fsharp.Core.dll

So, I am doing a simple personal project in winforms with F #. My code worked, but now throws this exception apparently for no reason.

An unhandled exception of type 'System.InvalidOperationException' occurred in FSharp.Core.dll

 Additional information: The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized.

Code is a member method that is called from the constructor of the form itself

    do
 //lots of other constructor code before this point
 // render the form
        form.ResumeLayout(false)
        form.PerformLayout()
        form.ReloadGoals



//several other members before here
    member form.ReloadGoals  =
        let x = 10  //crashes on this line

The website on which I took the template for the project I am using is this one . Unfortunately, I made some significant additions to this.

I would be happy to post more code, but I need to know which code will matter exactly since I am not completely sure and do not want it to fail the message in extraneous code.

System.InvalidOperationException. , , , , .

+4
2

. F # 3.0 ( , PDF), §8.6.1 :

; InvalidOperationException.

, . , - , .

:

type X() as this =
    let x = this.X
    member __.X = 42
X()

, . .

+6

, ( F # interactive, , ReloadGoals Form.Show, ). :

  • Form.Load, , . ? Load .

  • F #. , initControls - , , ; do. initControls do . form.ResumeLayout(false); form.PerformLayout() form.ResumeLayout(true), , . , , : , , - lambdas . ?!

, , , form . Load, .

, form . , FSI - :

open System.Drawing
open System.Windows.Forms

let form = new Form()
form.ClientSize <- new Size(600, 600)
form.Text <- "F# Form"

let formLabel = new Label()
formLabel.Text <- "Doubleclick test!"
formLabel.DoubleClick.Add <| fun _ -> form.Close() 
form.Controls.Add(formLabel)

form.Show()

. ( Application.Run .. form.Show().) , , , .

+5

Source: https://habr.com/ru/post/1568124/


All Articles