Reputation: 6586
I have a C# dll that I need to reference in F#. I can do this fine in a .fs file, but I can't seem to get it to work in an F# script (.fsx) It is strange because in my script, I have no problem referencing F# dlls. I thought C# dlls and F# dlls were essentially the same.
EDIT:
I have two dlls (1) csharp.dll and (2) fsharp.dll built with csharp and fsharp respectively. I reference them with:
#r "bin\Debug\csharp.dll"
#r "bin\Debug\fsharp.dll"
which the compiler recognizes. The line where this occurs looks like this:
let new_object = new fsharp.type(Observable<csharp.type>)
Where I'm creating an object defined in fsharp.dll which takes an observer of a type defined in csharp.dll. When I try to run it in FSharp interactive, I get the following error:
error FS0074: The type referenced through 'csharp.type' is defined in an assembly that is not referenced. You must add a reference to assembly 'csharp'.
The thing that doesn't make sense is that csharp.type had been used successfully in a previous line. But when we introduce the csharp.type with an fsharp.type, I get an error all of a sudden saying the csharp type is missing an assembly reference, even though the problem seems to be with the fsharp.type.
Upvotes: 0
Views: 1163
Reputation: 7877
@Petr is correct. You need to add all references, and their references.
If you are using Visual Studio, I suggest that you install Visual F# Power Tools. When installed, right-click 'References' under your project and choose to 'Generate references for F# interactive'.
This will generate (and keep updated!) the files
So in your F# script (assuming it is in the project root), you just do
#load "Scripts/load-project.fsx"
These generated files should go into your version control of choice.
Upvotes: 1
Reputation: 4280
It seems you'll need also refer in the script System.Reactive.dll
or wherever the class Observable<T>
is defined
Upvotes: 1