Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Nov 21, 2013 @ 11:10
    Dan
    1

    Trouble deploying to server: Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0'

    Hi,

    I have a client who is having difficulty getting their site deployed to their live server. The site is Umbraco 6.1.6. It works locally and on the staging server but on the live server (on a different hosting provider) they get the following error:

    Server Error in '/' Application.

    Could not load file or assembly 'System.Web.WebPages.Razor, 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) 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 'System.Web.WebPages.Razor, 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)

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

    WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

    Stack Trace:

    [FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, 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)]
    Microsoft.Web.Helpers.PreApplicationStartCode.Start() +0

    [InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.Helpers.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, 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) +550
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

    [HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.Helpers.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, 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) +9874840 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

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

    I've had them check that the server is running ASP.NET4, IIS has full or high trust and their permissions are supposedly correct.

    It seems to be something to do with the version of razor that's installed on the server but Googling hasn't yielded any useful results - only people changing which DLLs are included in their projects (it's just a standard Umbraco installation so I don't want to have to try re-compiling with different assemblies). Is it possible that they need to install Razor 1 on the server? Would that have any negative implications?

    Can anyone suggest what might be wrong and how to get this working?

    Many thanks folks...

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Nov 21, 2013 @ 11:14
    Stefan Kip
    1

    Check what version of MVC is running on these different environments. I think some run 3.0 and some run 4.0.

  • Dan 1288 posts 3921 karma points c-trib
    Nov 21, 2013 @ 11:16
    Dan
    0

    Thanks Stefan. Whilst I find this out, what version should it be? And is it typically possible to change from one to the other?

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Nov 21, 2013 @ 11:20
    Stefan Kip
    1

    Well I'd go with MVC 4, because it's newer and better ;-)
    When you upgrade to MVC 4, you should add assembly redirect(s):

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    
  • Dan 1288 posts 3921 karma points c-trib
    Nov 21, 2013 @ 11:23
    Dan
    0

    So you think they're running MVC 3 but they need to be running MVC 4 on their server? If they upgrade from 3 to 4 I need to include this code in the web.config file, right?

    I'm just wondering why this isn't just working as it is, as it's a standard Umbraco install and I've never had to do any assembly redirects or anything like this before.

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Nov 21, 2013 @ 11:35
    Stefan Kip
    0

    Because things change and sometimes you have to do things manually to get stuff to work, it's not magic ;-)

  • Dan 1288 posts 3921 karma points c-trib
    Nov 21, 2013 @ 12:15
    Dan
    0

    Thanks Stefan. If I need to make some changes that's fine - I'm just wondering why the v6.x sites I've set up until now work fine with no mods, but for some reason this site is erroring when it's loaded onto the clients host server. Apparently their server has both ASP.NET MVC3 and 4.

    In the web.config file there is already the following (which is just standard from the default v6.1.6 umbraco install and hasn't been changed at all):

    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <!-- Old asp.net ajax assembly bindings -->
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <!-- Ensure correct version of MVC -->
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <!-- Ensure correct version of HtmlAgilityPack -->
      <dependentAssembly>
        <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
        <bindingRedirect oldVersion="1.4.5.0-1.4.6.0" newVersion="1.4.6.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    

    Do I need to change these redirects? This is all well above my head to be honest, so any ideas as to how to get rid of the razor error here would be very much appreciated.

    Many thanks

  • Dan 1288 posts 3921 karma points c-trib
    Nov 21, 2013 @ 14:47
    Dan
    101

    It turns out that they're hosting on a 1and1 shared server, which is a no-go as far as I can tell (probably to do with their custom permissions configuration).

    Thanks for your help Stefan but I think this one is beyond rescue and a new host will need to be found.

    Incidentally I did manage to bypass the razor error by changing this:

    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
    

    ...to this:

    <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" />
    

    But then some other major issues cropped up - hence abandoning the host.

Please Sign in or register to post replies

Write your reply to:

Draft