FsiEvaluationSession cant find Fsharp.Core when hosted in another process.
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
### Problem
The constructor of `FsiEvaluationSession` cant find `Fsharp.Core `when FCS is hosted in another process.
I used v40.0 but this problem probably existed since FCS 34.0. see https://github.com/dotnet/fsharp/issues/9064
When FCS is hosted in another app ( [Rhino3d](https://www.rhino3d.com/) in my case) the directory at [`Directory.GetCurrentDirectory()`](https://github.com/dotnet/fsharp/blob/7b46dad60df8da830dcc398c0d4a66f6cdf75cb1/src/Compiler/Interactive/fsi.fs#L3213) in `fsi.fs `probably does not contain `FSharp.Core.dll`. A non-descriptive `StopProcessingExn` is raised.
The useful information about the problem is not in the exception, but only in the FSI error stream:
```
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\
```
### Workaround
The workaround is to set the current directory to the location of `FSharp.Core.dll` before calling `FsiEvaluationSession.Create(...)`
for example via:
`Directory.SetCurrentDirectory(Path.GetDirectoryName(Reflection.Assembly.GetAssembly([].GetType()).Location))`
It took me one year, two other issues on this repo, and the reading of the now more descriptive FSI error stream (since 40.0) in addition to the exception, to understand what the problem was and find this workaround.
Contributor guide
Assessment
This issue has not been assessed yet.