Adding Serilog to an existing project: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation
See original GitHub issueA few questions before you begin:
Is this an issue related to the Serilog core project or one of the sinks or community projects. This issue list is intended for Serilog core issues. If this issue relates to a sink or related project, please log on the related repository. Please use Gitter chat and Stack Overflow for discussions and questons.
Does this issue relate to a new feature or an existing bug?
- Bug
- New Feature
What version of Serilog is affected? Please list the related NuGet package.
<package id="Serilog" version="2.7.1" targetFramework="net471" /> <package id="Serilog.Sinks.Console" version="3.1.1" targetFramework="net471" /> <package id="Serilog.Sinks.File" version="4.0.0" targetFramework="net471" />
What is the target framework and operating system? See target frameworks & net standard matrix.
- netCore 2.0
- netCore 1.0
- 4.7
- 4.6.x
- 4.5.x
OS: Windows 10
Please describe the current behavior? When executing this line:
Host = WebHost.CreateDefaultBuilder()
.UseUrls($"http://{IpAddress}:55555", $"http://{hostName}:55555")
.UseContentRoot(pathToContentRoot)
.UseStartup<Startup>()
.Build();
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll [09:26:05 INF] WebHost.CreateDefaultBuilder(): Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [09:26:05 INF] InnerException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Please describe the expected behavior? Removing Serilog all together was fine. I assume this is because Serilog package was added.
If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem
- Create a WPF Application with .NET Framework 4.7.1.
- Add ASP.NET Core 2.0 Web API in WPF.
- Run the ASP.NET Core service under WPF. This all works without any issue without Serilog. However, I would like to use Serilog rather than my built-in too simple logger. And this is cause an issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Related StackOverflow Question
Hi @zachrybaker ,
If you reference netstandard project from old style csproj you won’t get Serilog.dll in output (check the
binfolder) because of indirection dependency to Serilog. Try to addSerilogpackage to your web forms project.😃
Hi Riza! Thanks for getting in touch.
Unfortunately most of these kinds of issues end up being machine-specific, or caused by bugs/limitations/intended behavior in Visual Studio, NuGet or
dotnet. It’s rare that we find the cause in the Serilog package itself.It’s also usually hard to reproduce the exact setup that produces the error - so we don’t generally try, unless an error is being reported widely.
If you’re able to dig in deeper, and figure out whether the problem is the Serilog package itself, or just something the SDK is doing incorrectly based on Serilog or one of its framework dependencies, the help would be appreciated. We’re eager to fix any issues that can be addressed by Serilog directly, and will happily commit time to that if the cause is found.
Hope this helps, and please keep us in the loop if you find additional information.
Nick