I am creating an example for our next F# meetup and have run into an issue.
I have downloaded the FSharp.Data v2.2.1 to try the JSON tutorials to parse (stock options) data downloaded from the web. I have been struggling with this issue for almost a week now. I have followed the suggestions seen in other posts including complete uninstall of packages suggestion. I ran into the same issue trying to use the CSV provider and decided to switch to JSON.
I have #load @"C:\ full path to dll ...\lib\net40\FSharp.Data.dll" For some reason I have to give the full path for the F# script file to recognize it.
The line open FSharp.Data has an error "The namespace 'Data' is not defined" Nuget package manager shows that FSharp.Data version:2.2.1 is installed. I have uninstalled and reinstalled all packages in the project several times but it does not change the error.
So I am stuck at that point. I could use some insights from anyone who has been down this path.
-
Does it work in F# Interactive? Also, when loading the library to F# Interactive try right clicking the library in the references folder (in Visual Studio project) and select the "Send to F# Interactive" option.PiotrWolkowski– PiotrWolkowski05/06/2015 01:45:47Commented May 6, 2015 at 1:45
-
I am only using F# Interactive only for this example. I tried your suggestion to do a right click in the references and I get an error "file may be locked by F# Interactive process"Conrad D'Cruz– Conrad D'Cruz05/06/2015 01:49:05Commented May 6, 2015 at 1:49
-
I've run into similar issue. Please check it, there are some suggestions in the comments: stackoverflow.com/q/27338504/3330348PiotrWolkowski– PiotrWolkowski05/06/2015 01:50:44Commented May 6, 2015 at 1:50
-
I used the last suggestion to add #r @"full pathname\FSharp.Data.dll" in addition to the #load @"full path name\FSharp.Data.dll" and it now recognizes the dll but when I try to use it to run a small example it has and error. "error FS0073: internal error: ParseInput: unknown file suffix for FSharp.Data.dll"Conrad D'Cruz– Conrad D'Cruz05/06/2015 01:58:20Commented May 6, 2015 at 1:58
1 Answer 1
The following steps worked for me. I started from a new F# project and did everything in F# Interactive.
- Right click references folder in the project manager.
- Select manage nuget packages
- Install FSharp.Data
Reference the library in F# Interactive:
\#r @"C:\Users\{Full project path}\packages\FSharp.Data.2.2.1\lib\net40\FSharp.Data.DesignTime.dll";;
I get the warning that the library is locked. But F# Interactive allows me to open it.
Open the library:
open FSharp.Data;;
Run
JsonProvider
on file with data:type Stocks = JsonProvider<"C:\msft.txt">;;
-
I followed your suggestions to the letter and created a fresh project. I did not use the #load like I did before but instead used right click on references to send FSharp.Data to F#Interactive. I did the full #r #"fullpathname\FSharp.Data.dll" and now it can find the JsonProvider. I can now proceed with solving the other issues. Thank you!Conrad D'Cruz– Conrad D'Cruz05/06/2015 11:51:32Commented May 6, 2015 at 11:51