Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create FsiEvaluationSession in .Net Core project #807

Closed
rookboom opened this issue Sep 21, 2017 · 2 comments
Closed

Cannot create FsiEvaluationSession in .Net Core project #807

rookboom opened this issue Sep 21, 2017 · 2 comments

Comments

@rookboom
Copy link

Please provide a succinct description of the issue.
When attempting to instantiate an FsiEvaluationSession object in a dotnet core project, I get the following exception:

Unhandled Exception: System.Exception: Error creating evaluation session: StopProcessingExn None
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1379.Invoke(String message)
at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, Boolean fsiCollectible, FSharpOption1 legacyReferenceResolver) at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.Create(FsiEvaluationSessionHostConfig fsiConfig, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, FSharpOption1 collectible, FSharpOption`1 legacyReferenceResolver)
at Program.main(String[] argv) in A:\playground\fsc.netcore\Program.fs:line 22

Repro steps

Provide the steps required to reproduce the problem

Create a dotnet core project:

mkdir fsc.netcore
cd fsc.netcore
dotnet new console -lang F#
dotnet add package FSharp.Compiler.Service -v 14.0.2

Edit the generated Program.fs file to look like this:

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



[<EntryPoint>]
let main argv =
    let sbOut = StringBuilder()
    let sbErr = StringBuilder()

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

    let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()

    let args = [|"fsi.exe";"--noninteractive";"--nologo";"--gui-"|]
    let fsi = FsiEvaluationSession.Create(fsiConfig, args, inStream, outStream, errStream)

    0 // return an integer exit code
  1. Build and execute the project:
dotnet build
dotnet run

You should see the error mentioned above

Here is the project as a zip archive:
fsc.netcore.zip

Expected behavior

I should be able to create an instance of the FSIEvaluationSession in a dotnet core project.

Actual behavior

Provide a description of the actual behaviour observed.

Known workarounds

None

Related information

Provide any related information

  • Operating system Windows 10
  • .NET Runtime, CoreCLR or Mono Version dotnet core 2.0
  • Editing Tools (e.g. Visual Studio Version) VS Code
@dsyme
Copy link
Contributor

dsyme commented Sep 25, 2017

cc @ncave

@rookboom There is some testing enabled for many .NET Core scenarios. I don't know if it is is being run regularly. IIRC the main problem is to get the set of references to pass to the compiler, and to get the exact command line flags right. Some dettails are here https://github.com/Microsoft/visualfsharp/blob/master/tests/service/Common.fs#L12

But as I said, I'm not certain that testing is activated and passing right now. Perhaps @ncave or @enricosada know. I will make a note that we need to revisit this and get this under CI

@dsyme dsyme added the bug label Nov 3, 2017
@Wingjam
Copy link

Wingjam commented Feb 13, 2018

Got the same issue! Waiting for a fix or a workaround. See -> https://stackoverflow.com/q/48710880/5154345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants