How do you solve the error message that looks like this?
`Binding session to 'C:\Program Files (x86)\NLog\.NET Framework 4.0\NLog.dll'...
error FS0193: API restriction: The assembly
'file:///C:\Program Files (x86)\NLog\.NET Framework 4.0\NLog.dll' has
already loaded from a different location. It cannot be loaded from a
new location within the same appdomain.
Code that triggers it, might look like this:
#r @"..\packages\NLog.2.0.0.2000\lib\net20\NLog.dll"
NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging()
It seems that FSI won't load from the given DLL other than by name, so this would sort the problem out:
#I @"..\packages\NLog.2.0.0.2000\lib\net20"
#r @"NLog.dll"
NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging()
#I
means to add that folder to the load-path
#r
means to reference by dll-path; focusing on name. This means that FSI will use the file name first, looking in the system-wide search path and only then try to use the string after #r
as a directory-relative hint.
So by doing it this way, you make the NLog load from your specified directory rather than a system-wide one.