I figured out how to make a namespace alias, and that at least keeps the compiler happy (no syntax errors, etc).

But, then when I try to use some Windows Forms (plots of data using ZedGraph, in my case) from within FSI, an exception is thrown:

1
System.TypeLoadException: Could not load type 'Esl.Common.Numerics.complex' from assembly 'Esl.Common, Version=1.3.0.0, Culture=neutral, PublicKeyToken=0f47b9c8b0926e99'.at Esl.Plotting.Controls.SmithChartControl.zedGraphControl1_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, Int32 iPt)at ZedGraph.ZedGraphControl.HandlePointValues(Point mousePt)at ZedGraph.ZedGraphControl.ZedGraphControl_MouseMove(Object sender, MouseEventArgs e)at System.Windows.Forms.Control.OnMouseMove(MouseEventArgs e)at System.Windows.Forms.Control.WmMouseMove(Message& m)at System.Windows.Forms.Control.WndProc(Message& m)at System.Windows.Forms.ScrollableControl.WndProc(Message& m)at System.Windows.Forms.ContainerControl.WndProc(Message& m)at System.Windows.Forms.UserControl.WndProc(Message& m)at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
By on 12/26/2007 9:44 AM ()

Well, as much as I <i>really<i> didn't want to (because of the number of dependencies and effort involved), I was forced to renamed my C# struct from "complex" to "Complex", and that got rid of all of the weird exceptions. So, for those out there building libraries in C# that want to keep F# users in mind, don't name your classes/structs "complex". Or any other word that is an F# built-in, for that matter. Hopefully that helps someone.

By on 12/26/2007 11:49 AM ()

Hi Matt,

This behaviour is odd - a C# type called "complex" should be usable from F# (at the very least either by fully qualified access, or by a type alias). And did the FSI exception really go away after a renaming?

Thanks!

don

By on 12/29/2007 12:22 PM ()

Hi Don,

Yes, the behavior is rather odd. Here's more details about my setup:

Before (when the exception was being thrown):
struct "complex" is defined in Esl.Common.dll
class SmithChartControl (which is a control on a SmithChart form) uses "complex" in Esl.Plotting.dll
Esl.Plotting.dll references Esl.Common.dll
My F# script (test1.fsx) uses #I and #r to reference both Esl.Common.dll and Esl.Plotting.dll
When the script does "smithChart.Show()" to show the form, it comes up and displays my form, with the control in it. The exception only happens when I mouse over the chart.
I think it only happens here because the "complex" struct isn't needed until that point. I have mouseover tooltips whose text depends on a calculation involving the "complex" struct in Esl.Common.

After:
Renamed struct "complex" to "Complex" in Esl.Common.dll
Recompiled everything (including Esl.Plotting.dll)
Ran the script (test1.fsx) and everything worked, including the mouseover text (that uses the "Complex" struct).

Esl.Common.dll and Esl.Plotting.dll are all written in C#.

-Matt

By on 12/29/2007 12:32 PM ()

And if you rename back to lower case... [8-)] ??

Thanks!

don

By on 12/29/2007 12:51 PM ()

Oh, well, it's going to stay upper case "Complex" seeing that it took me 3 days to go through the rest of my code and rename everything from "complex" to "Complex"...

Well, renaming stuff doesn't usually take that long, but I have a lot of unit tests, etc, and needed to rename everything in SVN, plus I had to rebuild my distribution packages and re-deploy them to my 30-machine computing grid.

By on 12/29/2007 12:55 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper