F#: Is Profile 47 required for Microsoft.FSharp.Da

2019-07-06 00:12发布

问题:

This is a follow-up to my post yesterday. To recap, I received this error message when trying to build my project:

FSC: Error FS2024: Static linking may not use assembly that targets different profile

I consulted some kind people in the F# fpchat.com channel, and one of them suggested that the error could be due to the fact that I did not have Profile 47, because FSharp.Data uses Profile 47. I tried downloading the target pack for Profile 47, but was redirected to the Microsoft homepage instead. I tried the second answer on this SO page, but that did not work either. As of now, I am still unable to acquire Profile 47.

I consulted the FSharp.Data GitHub page, but it is not clear to me why Profile 47 is needed. I use VS2013 compiling to FSharp.Core 4.3.0.0; shouldn't that be sufficient, since the GitHub page lists it as one of the supported platforms?

I have created a new project, re-added all my source files and references, and tried re-building. I have even tried uninstalling and then re-installing Microsoft VS, even though I know it is likely irrelevant.

I think it is most probable that the problem lies with referencing FSharp.Data.TypeProviders. The error message does not appear insofar as I exclude reference to FSharp.Data.TypeProviders. The strangest thing is that I have not changed my references at all over the past week or so, but the error message only appeared yesterday.

So, my questions are:

  1. Is Profile 47 really required? If so, how may I acquire it?
  2. Even if I do acquire Profile 47, wouldn't I still experience trouble building my project, since my other references do not target Profile 47?
  3. Are there any approaches that I may not have considered?

回答1:

After tearing my hair out trying a variety of suggested solutions I found online, I discovered that the only way to resolve the issue was to change my Target Framework from 4.5 to 4.0, re-install all of my references to ensure compatibility with .NET 4.0, and then re-build my solution. Using .NET 4.0 means that I am no longer able to use Microsoft.Experimental.Collections, since it is compatible only with .NET 4.5. This means that I will have to re-write all of my code that makes use of Microsoft.Experimental.Collections, but I consider that a lesser evil than not being able to build my project at all.

So, to answer my own question mentioned in the title, Profile 47 is not required to use FSharp.Data.TypeProviders. :-)

EDIT:

I have found another solution to my problem. I created a new project (again), migrated all my source files over, re-installed all the DLLs I need, and this time I have no trouble whatsoever building my project. I think Carsten (who wrote the first comment to this answer) is correct in saying that the versions became messed up in the original solution files.