简体   繁体   中英

Mvvm-light / Serilog design time error: Could not load file or assembly [VS2017]

I'm getting the error below in DesignTime when I have a view open which has a viewmodel with references to SeriLog.

Could not load file or assembly 'Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its dependencies. Het systeem kan het opgegeven bestand niet vinden. myapp C:\\snip\\Projects\\snip\\myapp\\myapp\\Views\\MyViews\\MyView.xaml

The dutch string translated to English: "The system can't find the file"

The project compiles and runs fine, but I'd like an error-free design-time experience. Right now this error breaks my design-time project code in VS2017. What can I do to fix this error?

Already tried:

  • Removing the serilog folder from %userprofile%.nuget and rebuilding
  • Cleaning the project folder bin\\ and obj\\ folder
  • Rebuilding the project
  • Restarting VS2017
  • Rebooting computer
  • Another workstation shows the same error
  • Compiling serilog and sink myself on netcore1.6 target

I'm building an UWP app targeting the anniversary edition 14393 framework.

project.json serilog references:

 "Serilog": "2.4.0",
 "Serilog.Sinks.RollingFile": "3.3.0",

Sample VS project which replicates the issue

I have created a blank Template10 project with mvvm-light viewmodel on DetailPage.xaml for which the serilog error is shown.

Download location:

https://www.dropbox.com/s/uocjx0kuc1dknwt/Template10_Serilog_Sample.zip?dl=0

Screenshot of error

在此输入图像描述

I think you are using higher .net framework version. I also faced same problem earlier in asp.net mvc project in vs2017, but my problem is resolved when i changed my target .net framework version to lower one.

Try to use the Package Manager to update.

Go to: Tools > Nuget Package Manager > Package Manager Console

And type it:

Update-Package Serilog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM