Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeric Yuen 334 posts 508 karma points
    Jun 28, 2016 @ 20:15
    Jeric Yuen
    0

    ModelsBuilder Microsoft.CodeAnalysis.CSharp Error

    Hi All,

    I'm using Umbraco 7.4.3 and had been randomly getting YSOD saying

    Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    

    The stack trace shows the following error not sure why.

    Stack Trace:

    [FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
       Umbraco.ModelsBuilder.Umbraco.LiveModelsProvider.get_IsEnabled() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\LiveModelsProvider.cs:27
       Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule.Install() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\LiveModelsProvider.cs:134
    
    [InvalidOperationException: The pre-application start initialization method Install on type Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule threw an exception with the following error message: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
       System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +874
       System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
       System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
       System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
    
    [HttpException (0x80004005): The pre-application start initialization method Install on type Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule threw an exception with the following error message: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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) +579
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716
    

    Anyone got any idea? Can't figure out what triggered the error. It happens randomly.

    I've done a search around and someone mentioned to delete the package folder of Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0 and then restore the nuget package. That fixes the problem.

    But from time to time it happens again which is not that great.

    Thanks

  • David Peck 615 posts 1646 karma points c-trib
    Jun 29, 2016 @ 07:37
    David Peck
    0

    Stupid question perhaps, but I take it that you actually have a reference to Microsoft.CodeAnalysis.CSharp in your project references?

  • David Peck 615 posts 1646 karma points c-trib
    Jun 29, 2016 @ 07:38
    David Peck
    0

    If it is as simple as that then type this in to your package manager console:

    Install-Package Microsoft.CodeAnalysis.CSharp -Version 1.0.0
    
  • Jeric Yuen 334 posts 508 karma points
    Jun 29, 2016 @ 09:31
    Jeric Yuen
    0

    had just got it checked, yup got Microsoft.CodeAnalysis.CSharp reference in my project. Will try to reinstall the package.

    Any idea why a reinstall on the package?

    Thanks David

  • David Peck 615 posts 1646 karma points c-trib
    Jun 29, 2016 @ 10:15
    David Peck
    0

    If the reinstall fixes the package then it could be that you've got only part of the nuget package in version control (so it doesn't restore any missing file).

  • BenH 59 posts 199 karma points
    Jul 22, 2016 @ 13:27
    BenH
    0

    I'm getting the same error at runtime, but when I use that command, Nuget says it already exists in the project, how do I reinstall it?

  • Craig100 1078 posts 2366 karma points c-trib
    Dec 12, 2016 @ 10:17
    Craig100
    0

    Same here. Just done a NUGET upgrade to 7.5.6 on a 7.4.3 Fanoe test site and carefully checked the config dir files and web.config, all ok. Already have a reference to Microsoft.CodeAnalysis.CSharp but still get YSOD: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

  • Craig100 1078 posts 2366 karma points c-trib
    Dec 12, 2016 @ 10:23
    Craig100
    0

    Fixed by doing a NUGET Update on the Microsoft.CodeAnalysis.

    HTH

  • Titu 1 post 74 karma points
    Jan 11, 2017 @ 02:39
    Titu
    3

    Fixed the issue by running following command in NuGet Package Manager Console:

    Update-Package -Reinstall Microsoft.CodeAnalysis.CSharp
    
  • Denford 130 posts 311 karma points
    Dec 19, 2017 @ 21:53
    Denford
    0

    Seems a common issue this, am on 7.7.4 updated some code done a rebuild and boom it went lol, seem the nuget re-install fixed it. I actually had to un install it first then re-install it again as i already had it installed and was picking up any update required.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies