Reputation: 21
I have an F# library that uses the .Net 4.5 HttpClient. It compiles just fine but when I try to call functions in the library after loading it in a script the script says it can't find System.Net.Http.
Both the script and the library are in the same project targeted at .Net 4.5.
The library (in TdApi.fs) does this open System.Net.Http; but when the script does this #load "TdApi.fs" the error in the interactive window is this TdApi.fs(6,17): error FS0039: The namespace 'Http' is not defined.
I'm using VS2012 and am just getting started in F#.
Upvotes: 2
Views: 153
Reputation: 243051
There is a difference between a compiled library and a script file.
When you compile your TdApi.fs
file as part of a library project, the dependencies (in your case, the HTTP library) are specified in project properties. The compiler uses the fsproj
file to find the dependencies (and so everything compiles fine).
When you #load
your TdApi.fs
file from a script, it does not know about the project - and so it also does not know about the dependencies. To fix this, you can either use #r "TdApi.dll"
where TdApi.dll
is the compiled library, or you can use something like:
#r "someplace/System.Net.Http.dll"
#load "TdApi.fs"
So, you can use #r
to explicitly load the HTTP library first and then TdApi.fs
will see it.
Upvotes: 4