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

2

7

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

enter image description here

Eggbeater answered 12/3, 2017 at 13:28 Comment(6)
Could you please provide the relative code snippet since I cannot reproduce your issue?Pundit
I have added a sample project download location to the post and a screenshot of the error I'm seeing after compilation in X86 debug mode.Eggbeater
My xaml design view works fine, my designer is not crashing and doesn't need to be reloaded. There also is no stack trace to view. So the design view works fine, however, my designtime data from my viewmodellocator isn't loaded in my xaml designer because of the serilog error. As soon as i comment the logging functions from my viewmodels, the desingtime data works just fine.Eggbeater
The issue is similar to #39472349, it seems that after removing the serilog package the solution still builds with the serilog.sink.rollingfile package aloneEggbeater
Could you please check your environment again? It has no error on my side with the project you uploaded. What's your os version? Did you use visual studio 2017 RC? My DetailPage with no error is showing here.Pundit
I can confirm this issue appears on two separate fully updated Win10 systems with the latest and updated version of VS2017 community edition. One of these is a clean install from MSDN. Make sure you set your project to Debug-X86 in order for project code to be enabled in design mode. Without this the error won't show as X86 debug mode is a requirement for running project code in design mode.Eggbeater
S
1

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.

Stacte answered 26/3, 2017 at 17:55 Comment(1)
Unfortunately changing the target UAP framework isn't realy an option for my project since I'm using functionality which was only added in the anniversary update.Eggbeater
D
0

Try to use the Package Manager to update.

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

And type it:

Update-Package Serilog
Divisibility answered 30/3, 2017 at 19:13 Comment(1)
Thanks but my NuGet packages are already up to date "No package updates are available from the current package source for project"Eggbeater

© 2022 - 2024 — McMap. All rights reserved.