Open goswinr opened 3 years ago
Can this be cheated with an assemblyloadcontext or assemblycontexthandler?
@JustinGrote Thanks for thinking about this. It seems that not so many people are hosting FSI. Would I have to use the AssemblyLoadContext for hosting FCS and FSI ?
Problem
The constructor of
FsiEvaluationSession
cant findFsharp.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 in my case) the directory atDirectory.GetCurrentDirectory()
infsi.fs
probably does not containFSharp.Core.dll
. A non-descriptiveStopProcessingExn
is raised.The useful information about the problem is not in the exception, but only in the FSI error stream:
Workaround
The workaround is to set the current directory to the location of
FSharp.Core.dll
before callingFsiEvaluationSession.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.