2016-09-25 47 views
2

我有一个C#程序调用这个F#代码snipet。在执行let fsiSession时,我得到下面的例外。这些site暗示了一些想法,但我不明白他们在说什么。我不知道在哪里找到了FSharp.Core.optdata。FSharp.Core.optdata没有在FSharp上找到.Core

namespace FsharpTestgSystem 

open System 
open System.IO 
open System.Text 

open System.CodeDom 
open Microsoft.FSharp.Compiler.SourceCodeServices 
open Microsoft.FSharp.Compiler.Interactive.Shell 
open Microsoft.FSharp.Compiler.SimpleSourceCodeServices 


type TestSystem() = 
    // Intialize output and input streams 
    // Build command line arguments & start FSI session 
    let argv = [| "C:\\Program Files (x86)\\Microsoft SDKs\\F#\\4.1\\Framework\\v4.0\\fsi.exe" |] 
    let allArgs = Array.append argv [|"--noninteractive"|] 

    let sbOut = new StringBuilder() 
    let sbErr = new StringBuilder() 
    let inStream = new StringReader("") 
    let outStream = new StringWriter(sbOut) 
    let errStream = new StringWriter(sbErr) 
    let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() 
    let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream) 

unknown(1,1): error FS1225: File '\bin\x64\Debug\FSharp.Core.optdata' not found alongside FSharp.Core 
unknown(1,1): error FS0229: Error opening binary ... 
+0

这是说它应该在SDK目录中。 [SO链接](http://stackoverflow.com/questions/21224314/what-are-fs-fsharp-core-optdata-and-fsharp-core-sigdata-files/)顺便说一句,我能找到的唯一地方这个文件在Fake/tools中。 – s952163

回答

3

我把直接引用到下面的一些实用程序我写了名字空间所需要的东西:

C:\ Program Files文件(x86)的\微软的SDK \ F#\ 4.0 \框架\ V4 .0 \ FSharp.Compiler.Interactive.Settings.dll

也许您可以将对此文件的引用传递给正在生成额外参数的进程。参见 - 参考这里:https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/compiler-options

注:FSI中的命令参数往往是相同的Fsc.exe

+0

这似乎工作。谢谢。 – Ivan

0

我得到了我的老项目这个错误安装VS 2017什么固定它,我是后:

  • 使所有文件的备份。

  • 安装从的NuGet最新版本FSharp.Core的(恰好是4.2.1现在)

  • 在项目属性:

    • 选择F#的最新版本作为目标运行时,刚巧为4.4.1.0。
    • 选择.NET Framework 4.7作为目标框架。