F # interactive, dll binding API restriction

How do you resolve an 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. 

The code that runs it might look like this:

 #r @"..\packages\NLog.2.0.0.2000\lib\net20\NLog.dll" NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging() 
+6
source share
1 answer

It seems that FSI will not load from this DLL except for the name, so this will save you from the problem:

 #I @"..\packages\NLog.2.0.0.2000\lib\net20" #r @"NLog.dll" NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging() 

#I means add this folder to the boot path

#r means link using dll-path; focusing on the name. This means that FSI will first use the file name, looking into the system-wide search path and only then try to use the line after #r as a hint for the directory.

Thus, by doing this in this way, you are loading the NLog from the specified directory, not the system-wide one.

+8
source

Source: https://habr.com/ru/post/909447/


All Articles