问题
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.
回答1:
@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.
回答2:
Have you checked the actual version of System.Web.WebPages.Razor
that is currently deployed to your bin folder? I had a similar issue recently in a multi-project solution and one of the projects was using an older version of the assembly via Nuget which happened to be the one that ended up in the bin folder causing a similar error. In fact I'm pretty sure that it's the Umbraco Nuget package copying in the older assembly.
回答3:
Finally, I have fixed this issue. Blog Engine's(Child application) Razor Script version is 2.0.0.0 and Umbraco(Parent application) 4.1.6 application's Razor script version is 1.0.0.0, i have added the below in child's web.config
<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>
Once the above added, i get rid of this error and i faced the same dependency errors for the below and i added the respective dependent assembly and the version.
Microsoft.Web.Helpers.dll
Examine.dll
Umbraco.dll
WebGrease.dll
For the above three dependency will not present in child application's bin folder, you need to copy the dll files from parent bin folder and add it in child bin folder, which will sort all the dependency issues.
For any deploying issues on BlogEngine as virtual directory and Umbraco as parent application, leave your message will help you solve the issue of any different versions.
回答4:
Please try the following steps.
- Check the Version of System.Web.Webpages in your References. Say Your Version is=X.X.X.X
2.In Webconfig
a.Add the assembly first
<assemblies>
<add assembly="System.Web.WebPages, Version=X.X.X.X, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
b.Bind the assembly for runtime
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-X.X.X.X" newVersion="X.X.X.X"/>
</dependentAssembly>
</assemblyBinding>
3.Make sure you have added correct key
<appSettings>
<add key="webpages:Version" value="X.X.X.X"/>
</appSettings>
This worked for me. Hope It'll help you too.
回答5:
Sometime, you will have mistake between
System.Web.WebPages.Razor
and
System.Web.Razor
Try look and check
回答6:
Create a new Area, right click project, Add, Area
Copy the web.config from the views folder in this area to /views/web.config
remove the area
来源:https://stackoverflow.com/questions/21375191/could-not-load-file-or-assembly-system-web-webpages-razor-version-2-0-0-0-cul