1

We recently deployed a Umbraco 7.1.9 application on a Windows Server 2012 VM hosted by Azure. The application works #1 locally on our developer machines but when we deploy the website on the VM we get this error:

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.Reflection.ReflectionTypeLoadException: Could not load types from assembly umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null, errors:
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.Editors.ContentPostValidateAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Could not load type 'System.Web.Http.Controllers.IControllerConfiguration' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Exception: System.TypeLoadException: Could not load type 'System.Web.Http.Controllers.IControllerConfiguration' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Exception: System.TypeLoadException: Could not load type 'System.Web.Http.Controllers.IControllerConfiguration' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.WebApi.Filters.EnsureUserPermissionForContentAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.WebApi.Filters.EnsureUserPermissionForMediaAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.WebApi.Filters.FileUploadCleanupFilterAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.WebApi.Filters.FilterAllowedOutgoingMediaAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'Umbraco.Web.WebApi.Filters.FilterAllowedOutgoingMediaAttribute'.  Assembly: 'umbraco, Version=1.0.5443.21812, Culture=neutral, PublicKeyToken=null'.
Exception: System.TypeLoadException: Could not load type 'System.Web.Http.Controllers.IControllerConfiguration' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Exception: System.TypeLoadException: Could not load type 'System.Web.Http.Dispatcher.DefaultHttpControllerSelector' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

We installed the latest version of .NET Framework, every updates on the server and we can't get it to work.

Anyone got a similar issue?

Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57

2 Answers2

1

EDIT: Useful thread here...

http://our.umbraco.org/forum/getting-started/installing-umbraco/48351-Umbraco-703-is-totally-broken-after-fresh-nuget-install

This didn't help...

I haven't seen that problem yet but I'm diffing Web.config to upgrade from 7.1.4 to 7.1.9 today and I've noticed two things that might help you.

  1. This was added recently:

    <add assembly="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    
  2. There is nothing like this in Web.config for System.Web.Http:

    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
    

Makes me wonder if the answer to your problem might be adding this:

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>

Or this (seen here):

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
Community
  • 1
  • 1
twamley
  • 801
  • 2
  • 14
  • 22
  • Thanks but it does not seem to do a difference. In fact the `System.Web.Http` was not defined but it did not fix our issue. I also tried with 5.2.2.0 but Umbraco is using 4.0.0.0 version, so when I specify the 5.2.2.0 version I get this exception: `Could not load file or assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.` – Charles Ouellet Nov 28 '14 at 19:53
  • Bummer. The upgrade went smooth on our internal Windows Server 2012 R2. /bin/System.Web.Http.dll is the same version that was in 7.1.4: 4.0.20710.0. /bin/umbraco.dll is now 1.0.5443.21812 same as in your error message. Maybe ``? I know I'm grasping for straws now. I'll let you know if I notice any problems deploying to an Azure Website (not VM sorry). – twamley Nov 28 '14 at 21:12
  • 1
    Found a thread with a nearly identical error message from people upgrading to 7.0.3. There are some workarounds listed in there like clearing /bin and restoring packages. Also one about making sure you have the exact right version of WebApi (probably not 4.0.30506 anymore). http://our.umbraco.org/forum/getting-started/installing-umbraco/48351-Umbraco-703-is-totally-broken-after-fresh-nuget-install – twamley Nov 28 '14 at 21:32
  • Yeah I saw this post before posting this question. I tried to remove `Microsoft.AspNet.WebApi` package and install it manually using `4.0.30506` version which is still the one used in Umbraco but no difference :( I tried installing the application on a Windows Server 2008 machine, same issue. – Charles Ouellet Dec 01 '14 at 14:21
  • Just got it working. But I don't consider it as a real solution, I took `System.Net.Http.Formatting` and `System.Web.Http` dll files from a Umbraco 7.1.8 project and replaced the original ones in the `bin` folder. Now it works. Seriously there is something I don't understand! – Charles Ouellet Dec 01 '14 at 14:32
  • Noticed that the .dll version (in the file properties) is `4.0.20701.0` instead of `4.0.20126.16343` – Charles Ouellet Dec 01 '14 at 14:38
  • 1
    Ok, found out the issue! We added the `LowercaseRoutesMVC4` package that depends on `AspNetWebApi.Core` which is an unlisted package. It references a bad version of `System.Web.Http`. I uninstalled this package, used the `LowercaseUrls` property in my route configuration instead of the NuGet package and now everything works as expected. Thanks for the help and moral support :) – Charles Ouellet Dec 01 '14 at 16:51
1

Not sure it will be helpful for anyone else having this issue as it is very specific to our project.

We added the LowercaseRoutesMVC4 package that depends on AspNetWebApi.Core which is an unlisted package. It references a bad version of System.Web.Http. I uninstalled this package, used the LowercaseUrls property in my route configuration instead of the NuGet package and now everything works as expected.

Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57