I have a list of DLL load instructions that looks like this:
#I __SOURCE_DIRECTORY__
#r @"packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll"
#r @"packages\Akka\lib\net45\Akka.dll" ...
Note that the list references Newtonsoft.Json.dll (the version 7.0.1). But when I execute in FSI the code that uses the references DLLs Visual Studio loads Newtonsoft.Json from a different place, as shown in its log:
Binding session to 'C:\Projects\Samples\fsharpreactivepatterns\packages\Akka\lib\net45\Akka.dll'... Binding session to 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll'...
The Newtonsoft.Json.dll doesn't even point to one of the Visual Studio 2015 folders, it references the DLL from the Visual Studio 2013 that is also installed on my machine.
Here's the workaround I've found so far:
#I __SOURCE_DIRECTORY__
#r @"packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll"
let c = Newtonsoft.Json.Converters.DiscriminatedUnionConverter
#r @"packages\Akka\lib\net45\Akka.dll"
Now FSI loads and uses correct Newtonsoft.Json version.
Is there a better way to ensure FSI uses DLL paths specified in #r directive?
I think that if you #I to the folder where JSON.Net lives, it might find it from there. But I agree, I've seen this behaviour as well from time to time, it's not intuitive.