Reputation: 12104
I'm attempting to make a gui application in F# that uses a dialog box to open a file however whenever I try to use it, the program crashes with that exception here's my code:
let openAndDrawChart e =
let dlg = new OpenFileDialog(Filter="CSV Files|*.csv")
if dlg.ShowDialog() = DialogResult.OK then // code crashes here
let pieChart = drawChart dlg.FileName
boxChart.Image <- pieChart
btnSave.Enabled <- true
If I try to put a try with block around it, the program just crashes after the "with" keyword
Also, if I replace the code following then
with a ()
then the program still crashes, the code never gets past the if ... then
statement
So does anyone here know what I'm doing wrong, and how I can fix it?
I just want to point out that I'm more accustomed to making gui applications in C#, so trying to do it in F# is new to me
Here's the exception's exact words:
Upvotes: 2
Views: 1328
Reputation: 12104
OK so, this is a little bit embarrassing but apparently the program doesn't play well with an entry point...
At the bottom of my code I had this:
[<EntryPoint>]
let main args =
0
Which I just removed...
I didn't think it mattered much since the program executed the code above the entry point anyway
But apparently it was was enough to mess up the whole thing!
Sorry for the inconvenience, though it might be a good thing to leave this here for future reference
Upvotes: 7