0
votes

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.

1
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
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
I've run into similar issue. Please check it, there are some suggestions in the comments: stackoverflow.com/q/27338504/3330348 - PiotrWolkowski
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

1 Answers

1
votes

The following steps worked for me. I started from a new F# project and did everything in F# Interactive.

  1. Right click references folder in the project manager.
  2. Select manage nuget packages
  3. Install FSharp.Data
  4. 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.

  5. Open the library:

    open FSharp.Data;;
    
  6. Run JsonProvider on file with data:

    type Stocks = JsonProvider<"C:\msft.txt">;;