Win7, VSCode, F# Interactive. Could not load file or assembly 'System.Windows.Forms.DataVisualization"
Hello, All!
As far as I understand, System.Windows.Forms.DataVisualization is a system assembly. You don't need to explicitly refer to it. Why FSharp.Charting can't find an assembly? See attachment. What am I doing wrong?

Do we have an update on this error? FSharp.Charting is unusable in interactive at the moment. I've tried to load the missing dll with this input at the start of the program:
#I @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\"
The interactive console will show the binding:
Binding session to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.DataVisualization.dll'...
But the error remains the same. Reference to any other assembly versions didn't solve the issue. Can we have a link to the System.Windows.Forms.DataVisualization.dll we need to refer to?
You're running F# Interactive for .net core. You will need to use .net framework. I believe only Visual Studio has a legacy switch for running fsi for .net framework from the IDE.
You can run it from the command line using "fsi" from a vs2022 developer prompt.
I don't know if System.Windows.Forms.DataVisualization.dll is available for netcoreapp/net5/6, if it is we could add support for that
Looks like it's all considered deprecated for netcore, unless someone else is maintaining a fork.
https://github.com/dotnet/winforms-datavisualization
Still there is a partial nuget available. Perhaps it's enough to use in practice
Thanks @dsyme, the fsi command in vs2022 developer prompt is doing the job. I'll let the Interactive programming aside for now.
FWIW, I am able to use the copy of FSharp.Charting.fs with https://github.com/dotnet/winforms-datavisualization in net6.0 scripting with FSharp.Compiler.Service. I had to comment out the context menu code (to be continued). But overall it all works well.
The menu issue is solved - in net core apps ContextMenuStrip is used instead of ContextMenu.
let menu = new ContextMenuStrip()
let dlg = new SaveFileDialog(Filter = "PNG (*.png)|*.png|Bitmap (*.bmp;*.dib)|*.bmp;*.dib|GIF (*.gif)|*.gif|TIFF (*.tiff;*.tif)|*.tiff;*.tif|EMF (*.emf)|*.emf|JPEG (*.jpeg;*.jpg;*.jpe)|*.jpeg;*.jpg;*.jpe|EMF+ (*.emf)|*.emf|EMF+Dual (*.emf)|*.emf")
let miCopy = new ToolStripMenuItem("&Copy Image to Clipboard", ShortcutKeys = (Keys.Control ||| Keys.C))
let miCopyEmf = new ToolStripMenuItem("Copy Image to Clipboard as &EMF", ShortcutKeys = (Keys.Control ||| Keys.Shift ||| Keys.C))
let miSave = new ToolStripMenuItem("&Save Image As..", ShortcutKeys = (Keys.Control ||| Keys.S))
let miEdit = new ToolStripMenuItem("Show Property &Grid", ShortcutKeys = (Keys.Control ||| Keys.G))
miEdit.Click.Add(fun _ ->
miEdit.Checked <- not miEdit.Checked
props.Visible <- miEdit.Checked)
miCopy.Click.Add(fun _ ->
srcChart.CopyChartToClipboard())
miCopyEmf.Click.Add(fun _ ->
srcChart.CopyChartToClipboardEmf(self))
miSave.Click.Add(fun _ ->
if dlg.ShowDialog() = DialogResult.OK then
let fmt =
match dlg.FilterIndex with
| 1 -> ChartImageFormat.Png
| 2 -> ChartImageFormat.Bmp
| 3 -> ChartImageFormat.Gif
| 4 -> ChartImageFormat.Tiff
| 5 -> ChartImageFormat.Emf
| 6 -> ChartImageFormat.Jpeg
| 7 -> ChartImageFormat.EmfPlus
| 8 -> ChartImageFormat.EmfDual
| _ -> ChartImageFormat.Png
chart.SaveImage(dlg.FileName, fmt |> int |> enum) )
menu.Items.Add(miCopy) |> ignore
menu.Items.Add(miCopyEmf) |> ignore
menu.Items.Add(miSave) |> ignore
menu.Items.Add(miEdit) |> ignore
self.ContextMenuStrip <- menu