locked
Web Configuration Error RRS feed

  • Question

  • User1421620300 posted

    I need help with the following error. Trying to get new app up and running. Markus

    Server Error in '/' Application.


    Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Source Error: 

    Line 19:             AreaRegistration.RegisterAllAreas();
    Line 20: 
    Line 21:             WebApiConfig.Register(GlobalConfiguration.Configuration);
    Line 22:             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    Line 23:             RouteConfig.RegisterRoutes(RouteTable.Routes);


    Source File: C:\Users\Andrew\Documents\Visual Studio 2017\Projects\SinglePageAngularJS\SinglePageAngularJS\SinglePageAngularJS\Global.asax.cs    Line: 21 

    Stack Trace: 

    [FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
       System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() +0
       System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() +41
       System.Web.Http.HttpConfiguration.DefaultFormatters() +23
       System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes) +44
       System.Web.Http.GlobalConfiguration.<.cctor>b__0() +69
       System.Lazy`1.CreateValue() +411
       System.Lazy`1.LazyInitValue() +152
       System.Lazy`1.get_Value() +75
       System.Web.Http.GlobalConfiguration.get_Configuration() +22
       SinglePageAngularJS.MvcApplication.Application_Start() in C:\Users\Andrew\Documents\Visual Studio 2017\Projects\SinglePageAngularJS\SinglePageAngularJS\SinglePageAngularJS\Global.asax.cs:21
    
    [HttpException (0x80004005): Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
       System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +475
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +219
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303
    
    [HttpException (0x80004005): Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +658
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +188
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3160.0

    Friday, November 16, 2018 2:20 PM

Answers

All replies

  • User1724605321 posted

    Hi Markus33,

    Please try to reinstall the package :

    update-package Newtonsoft.Json -reinstall

    You can also refer to below threads which discuss same error message as yours :

    https://stackoverflow.com/questions/22507189/could-not-load-file-or-assembly-newtonsoft-json-version-4-5-0-0-culture-neutr

    https://stackoverflow.com/questions/12027543/visual-studio-2012-web-api-project-wont-run-cant-find-newtonsoft-json 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 19, 2018 9:05 AM
  • User1421620300 posted

    Hello, Nan i tried installing the package that you mentioned but now i receive the following error as a result? Can you help! Markus

    One or more unresolved package dependency constraints detected in the existing packages.config file. All dependency constraints must be resolved to add or update packages. If these packages are being updated this message may be ignored, if not the following error(s) may be blocking the current package operation: 'DotNetOpenAuth.Core 4.0.3.12153 constraint: CodeContracts.Unofficial '
    update-package : Unable to resolve dependency 'CodeContracts.Unofficial'. Source(s) used: 'nuget.org', 'ReactJS.NET Dev', 'Microsoft Visual Studio Offline Packages'.
    At line:1 char:1
    + update-package Newtonsoft.Json -reinstall
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Update-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand

    Monday, November 19, 2018 3:28 PM
  • User1421620300 posted

    Nan. the package had to be older version than one that i had installed. But after some thought i knew that the force uninstall would hit the target. And it worked successfully! Markus.

    uninstall-package newtonsoft.json -force

    install-package newtonsoft.json -version "5.0.6"

    Tuesday, November 20, 2018 5:42 PM