Adding Serilog to an existing project: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation

See original GitHub issue

A 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

  1. Create a WPF Application with .NET Framework 4.7.1.
  2. Add ASP.NET Core 2.0 Web API in WPF.
  3. 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
skomis-mmcommented, Aug 19, 2020

Hi @zachrybaker ,

If you reference netstandard project from old style csproj you won’t get Serilog.dll in output (check the bin folder) because of indirection dependency to Serilog. Try to add Serilog package to your web forms project.

1reaction
nblumhardtcommented, Sep 13, 2018

Add ASP.NET Core 2.0 Web API in WPF

😃

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Could not load file or assembly 'System.Runtime. ...
My project has an indirect dependency to System.Runtime.InteropServices.RuntimeInformation only. It is a dependency of a NuGet package I ...
Read more >
Cannot load file or assembly 'System.Runtime'
I have an Asp.Net 4.7 WebForms legacy application written in vb.net. To add Azure B2C authentication, I add OWIN middleware NuGet packages ...
Read more >
Assembly Manifest doesn't match reference
This article helps you resolve an error (The located assembly's manifest definition does not match the assembly reference) that occurs when a ...
Read more >
[Solved]-Could not load file or assembly 'System.Runtime ...
My project has an indirect dependency to System.Runtime.InteropServices.RuntimeInformation only. It is a dependency of a NuGet package I imported.
Read more >
Setting up Serilog in ASP.NET Core - Detailed Beginner ...
This article covers the implementation of Serilog in ASP.NET Core which provides structured logging that is easier to be read by programs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found