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

since release of FCS 34.0.1: FSharp.Core.dll was not found or is invalid #9064

Closed
goswinr opened this issue Apr 28, 2020 · 8 comments
Closed
Assignees
Labels
Area-FCS Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@goswinr
Copy link
Contributor

goswinr commented Apr 28, 2020

Since release of FSharp.Compiler.Service 34.0.1 (and higher versions too) I get this error

error FS0084: Assembly reference 'FSharp.Core.dll' was not found or is invalid

when calling FsiEvaluationSession.Create(...) hosted in a Rhino3d Plugin

Is version 33.0.1 using another version of FSharp.Core than 34.0.1 ?
May it be possible to fix this by telling the Rhino.PlugIn how to explicitly reference FSharp.Core ?
With binding redirects?
cc @sbaer @jesterKing

Here is a minimal repro to reproduce this :
https://github.com/goswinr/FsiRhinoTest

I previously reported this on FCS fsharp/fsharp-compiler-docs#935

@sbaer
Copy link

sbaer commented Apr 28, 2020

You could try forcing FSharp.Core.dll to load by using Assembly.LoadFrom in the plug-in's OnLoadPlugIn override.

@cartermp
Copy link
Contributor

@goswinr Try removing this: <PackageReference Update="FSharp.Core" Version="4.7.0" />

Explicit FSharp.Core references are only useful for library authors looking to pin their lowest-compatible FSharp.Core for consumers.

goswinr added a commit to goswinr/FsiRhinoTest that referenced this issue Apr 28, 2020
@goswinr
Copy link
Contributor Author

goswinr commented Apr 29, 2020

Is there a way to have more diagnostic error messages?
@cartermp , unfortunately removing the FSharp.Core package reference did not help.
how is dotnet build deciding which version of FSharp.Core to put in the output folder now?
@sbaer Explicitly loading it does not make a change either.

I included these suggestions in the test repro.

@dsyme dsyme added the Bug label Sep 1, 2020
@cartermp cartermp added this to the Backlog milestone Sep 1, 2020
@dsyme
Copy link
Contributor

dsyme commented Sep 3, 2020

@goswinr Did you make progress on this? I can look at your repro if you like

@dsyme dsyme added the Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. label Sep 3, 2020
@goswinr
Copy link
Contributor Author

goswinr commented Sep 4, 2020

@dsyme Yes, it would be great if you could look at the test repro. Follow the steps in the readme.
I just tried with the latest 37.0.0 nuget. same message:

Microsoft (R) F# Interactive version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> 

error FS0084: Assembly reference 'FSharp.Core.dll' was not found or is invalid

Would it be possible to have a better error message? Detailing why it is invalid ?

I saw some binding errors in the fusion log . ( using this tool https://github.com/awaescher/Fusion)
image

but I am not sure they are relevant. version 33.0.1 also shows similar errors.

@goswinr
Copy link
Contributor Author

goswinr commented Jul 1, 2021

With FCS 40.0 I still get the same StopProcessingExn exception in FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(..)
in addition, the FSI error stream says:

error FS0078: Unable to find the file 'FSharp.Core.dll' in any of
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF
 C:\Program Files\Rhino 7\System
 C:\Program Files\Rhino 7\System\

however, I can't put Fsharp.Core in any of those directories because of insufficient user rights.
Is there any way to make the FsiEvaluationSession constructor load FSharp.Core.dll from the same location as FSharp.Compiler.Service.dll ?

@KevinRansom there is also no app.config that i could modify as suggested here #10467 (comment)

@goswinr
Copy link
Contributor Author

goswinr commented Jul 2, 2021

After more than a year, I finally managed to fix this. 🎉
The constructor of FsiEvaluationSession queries the current directory.
However, when FCS is hosted in another app, this directory probably does not contain FSharp.Core.dll in my case it is C:\Program Files\Rhino 7\System\
So to fix this, I had to set the current directory to the location of FSharp.Core.dll befor calling FsiEvaluationSession.Create(...) . I added:
Directory.SetCurrentDirectory(Path.GetDirectoryName(Reflection.Assembly.GetAssembly([].GetType()).Location))
Now it works !

@JustinGrote
Copy link

Just a bump that I was bit by this while hosting the FCS compiler in .NET 8. @goswinr's workaround worked for me (thank you for your suffering)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FCS Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

No branches or pull requests

5 participants