嵌入F#Interactive throw System.Exception:'创建评估会话时出错:StopProcessingExn无'

时间:2018-02-09 17:12:05

标签: f# .net-core f#-interactive .net-core-2.0

我正在使用来自here的嵌入式F#互动示例,但就像post一样,我遇到了以下行引发异常的问题:

let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream)

抛出的异常是:

" System.Exception:'创建评估会话时出错:StopProcessingExn无'"

我的项目正在从VS2017 Enterprise运行,设置为一个简单的F#控制台应用程序,目标框架为.NET Core 2.0。从nuget下载的FSharp.Compiler.Service版本为17.0.1,FSharp.Core为4.2.0。

我运行的Program.Fs文件代码在这里(示例的直接端口):

open System
open System.IO
open System.Text
open Microsoft.FSharp.Compiler.Interactive.Shell

[<EntryPoint>]
let main argv =

    let sbOut = new StringBuilder()
    let sbErr = new StringBuilder()
    let inStream = new StringReader("")
    let outStream = new StringWriter(sbOut)
    let errStream = new StringWriter(sbErr)

    // 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 fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
    let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream)

    /// Evaluate expression & return the result
    let evalExpression text =
        match fsiSession.EvalExpression(text) with
        | Some value -> printfn "%A" value.ReflectionValue
        | None -> printfn "Got no result!"

    evalExpression "42+1" // prints '43'

    Console.ReadLine() |> ignore

    0  // return integer

我已经尝试将文件FSharp.Core.optdataFSharp.Core.sigdata添加到我的bin文件夹(bin \ Debug \ netcoreapp2.0)中,如herehere所述,但没有成功。顺便说一句,我的bin文件夹不包含文件FSharp.Core.dll

我还尝试发布我的应用并在发布文件夹中手动添加.optdata.sigdata文件,但也没有成功。

任何想法都会受到赞赏。

0 个答案:

没有答案