Search code examples
asp.net-mvcrazoriis-6umbracoblogengine.net

Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, or one of its dependencies


Please somebody help me fix this issue.

Umbraco application as parent on IIS6 has the following version of System.Web.WebPages.Razor.

  <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  </sectionGroup>

  <system.web.webPages.razor>
  <host factoryType="System.Web.WebPages.Razor.WebRazorHostFactory, System.Web.WebPages.Razor" />
  <pages pageBaseType="System.Web.WebPages.WebPage">
  <namespaces>
    <add namespace="Microsoft.Web.Helpers" />
    <add namespace="umbraco" />
    <add namespace="Examine" />
  </namespaces>
</pages>

Blog Engine application as virtual directory under the Umbraco application on IIS6 has the following version of System.Web.WebPages.Razor.

<configSections>
<remove name="system.web.webPages.razor" />
</configSections>

<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>

<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>

Even after i added the dependentAssembly still nothing works for me, Am wasting more than a week on this issue, Please help.


Solution

  • @ProNotion is right, I have seen more and more packages on Umbraco relying on specific versions of assemblies causing assemblies to conflict especially if two packages need different versions of the same assembly.

    So some other tips:

    This tool from MS helps diagnose assembly binding problems (http://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.71%29.aspx).

    Adding a runtime / assemblyBinding section to your web.config can work round problems with clashing assemblies (http://msdn.microsoft.com/en-us/library/0ash1ksb(v=vs.110).aspx)

    Sometime the assembly doesn't get copied (eg you use msbuild and the assembly isn't included in the project) - so you should also check to see if the assembly made it to the live server.