It would seem that .NET Interactive uses Serilog internally and this causes problems when trying to use Serilog.dll in a script
I found the Serilog.dll here .nuget\packages\microsoft.dotnet-interactive\1.0.522904\tools\net8.0\any but it was an older version. I loaded the following
#r "nuget:Microsoft.Extensions.Logging,8.0.0" #r "nuget:Serilog, 4.0.2" #r "nuget:Serilog.Extensions.Logging, 8.0.0" #r "nuget:Serilog.Settings.Configuration, 8.0.2" #r "nuget:Serilog.Sinks.Console, 6.0.0" #r "C:\Users\GARDNERJ.nuget\packages\serilog\4.0.2\lib\net8.0\Serilog.dll" #r "C:\Users\GARDNERJ.nuget\packages\serilog.extensions.logging\8.0.0\lib\net8.0\Serilog.Extensions.Logging.dll"
But on run got FileIOException unable to load Serilog.dll the hash matched the version in the path at the top but the packages were installed to the path pointed to by #r. I had to replace the Serilog.dll from where it was installed to the path at the top. Then it could load the Serilog.dll. My guess is that .NET Interactive used Serilog.dll but an older version.
Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):
1.0.522904+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074
- OS
- [ x] Windows 11
- [ ] Windows 10
- [ ] macOS
- [ ] Linux (Please specify distro)
- [ ] iOS
- [ ] Android
- Browser
- [ ] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari
- Frontend
- [ ] Jupyter Notebook
- [x ] Jupyter Lab
- [ ] nteract
- [x ] Visual Studio Code
- [ ] Visual Studio Code Insiders
- [ ] Visual Studio
- [ ] Other (please specify)
Screenshots
Besides the file IO exception unable to load DLL it was also issuing a warning which is probably more to the point:
The 2.0.0.0 version was the version in the .net interactive package location that's the one I replaced. There is no 4.0.0.0 with the has indicated. The hash for 4.0.0.0 was different.
Here is a screenshot of the Serilog.dll I replaced with the latest Serilog.dll. You can see this is the same hash that it was trying to load. located here: userprofile.nuget\packages\microsoft.dotnet-interactive\1.0.522904\tools\net8.0\any\Serilog.dll
. I needed it to load the installed package. I couldn't get it to do that so I just replaced the dll with the correct one and then my script executed just fine.
This PR might resolve this for you tactically.
Allowing completely separate assemblies from the ones that .NET Interactive itself depends on is a larger piece of work that's been discussed but so far not worked on.