Window Update Broke MVC Application - asp.net-mvc

I ran Windows Update yesterday and its introduced some problems when I'm trying to release a new version of my ASP.NET MVC 4 project.
The application compiles and runs okay locally, however when I push the version up to a test-site on my webserver it fell over with the error message:
System.Web.HttpCompileException: (0): error CS1705: Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
After some research I found that this is due to an update from 4.0.0.0 to 4.0.0.1. I removed the System.Web.Mvc dll from my project and readded the dll that has the later version. Again everything works locally but not on the web. I then went through the web.config's and changed any mention of 4.0.0.0 to 4.0.0.1. Likewise this continues to work internally but fails externally. The error message is:
Could not load file or assembly 'System.Web.Mvc, Version=3.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.Mvc, Version=3.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.Mvc, Version=3.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].
I believe this has something to do with Elmah that I'm using for the error handling.
I tried to reinstall from Nuget as suggested here: Windows update caused MVC3 and MVC4 stop working but that hasn't worked and I'm getting the same error.
Added info:
The server hasn't yet been updated, I'm concerned that updating this might break the existing live version.

The error message is telling me that you have specified an incorrect version number for the MVC assembly in one of your config files. Find it the config file with the incorrect version and change it to match whatever version you are using (you mentioned 4.0.0.1 above). You need to check all the config files including
The one in the project root
The one in the Views folder
You could also do an assembly redirect in your config file to take care of this as well -- If its failing due to a third party lib this might be the most appropriate action to take.
Based on your feedback id suggest using a binding redirect. Add this to your main web.config..
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.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.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>

I had a similar problem where a MS update changed MVC.dll from 3.0.0.0 to 3.0.0.1. I need to maintain various versions of my software so to ensure compatibility I had to copy the 3.0.0.0 dll to my project and reference it there before building the project.

After digging down some more, I found the web.config inside the view folder is pointing to different version System.web.mvc . Once I changed to
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
from
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
change version of System.Web.MVC to 4.0.0.0 from 4.0.0.1
I was able to solve the issue.

Related

Could not load file or assembly System.Runtime.CompilerServices.Unsafe on a clean autofac.mv5 installation

I just installed autofac.Mvc5 6.0 on my .net framework 4.7.2 installation.
And without adding any code other than adding the nuget package I get this error:
Could not load file or assembly
System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of it's
dependences. The found Assembly's manifest definition does not match
the Assembly reference. (Exception from HRESULT: 0x80131040)
Anyone got any idea?
You probably have another library that uses a different version of System.Runtime.CompilerServices.Unsafe. What's in web.config?
Did you tried bindingRedirect?
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
If you have a newer version replace it in the newVersion above.

Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ASP.NET MVC

I went through many answers that answered before but I'm not lucky to find a solution of my problem. This Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and many others I used.
****Here is the runtime error:****
Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.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=3.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=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/menupoly/abdulla/men1/MenuSnaps/
LOG: Initial PrivatePath = C:\menupoly\abdulla\men1\MenuSnaps\bin
Calling assembly : Microsoft.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\menupoly\abdulla\men1\MenuSnaps\web.config
LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/Temporary ASP.NET Files/root/c0c49273/dff4168/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/Temporary ASP.NET Files/root/c0c49273/dff4168/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL.
LOG: Attempting download of new URL file:///C:/menupoly/abdulla/men1/MenuSnaps/bin/System.Web.WebPages.Razor.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.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=3.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(ICollection1 methods, Func1 setHostingEnvironmentCultures) +613
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[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=3.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) +9946024
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
**This is the portion of my Web.Config**
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<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.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<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>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<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>
</assemblyBinding>
I verified the version of each on Reference are the same as on Web.Config. Please help me. Thank you for your help.
You have this binding redirection in web.config which mentions Razor 2.0 is being used instead of Razor 3.0, and you're trying to use Razor 3.0 assembly which not bound to anything:
<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>
The first thing you should do, change the binding redirection to use version 3.0 instead:
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
Also ensure that these configuration lines exist in web.config inside Views folder:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
If it still doesn't work & you're not sure that Razor package is properly installed, try reinstall the required packages with NuGet Gallery/Package Manager Console command (with -reinstall switch), then do given step above:
Update-Package –reinstall Microsoft.AspNet.WebPages
Update-Package -reinstall Microsoft.AspNet.Razor
NB - This assembly binding indicates that MVC 4 is being used:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
I recommend to upgrade your MVC project to version 5.0.0 and update Razor bindings to version 3.0.0 as suggested in this reference:
How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2 (Microsoft Docs)
Similar issues:
Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0
Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0
Before trying anything else,
I would suggest removing all files from the bin and obj folder Manually to ensure the new build generates files what is referred to in solution.
Usually, this happens when changing branches from shared projects/main projects.
Hope that saves some efforts in the world of .NET
I was getting the same error few days ago. After searching for one whole day I found the solution.
May be this could help you.
1. Check your Server's Path "C:\Program Files (x86)\Microsoft ASP.NET".
Is there any folder named "ASP.NET MVC 4" ?
2. If not you need to install ASP.NET Framework 4 in your server.
(if your project is in Framework 4.0)
When you encounter this kind of error related to MVC while deploying your app on a IIS server which is not the development machine, this is because you probably don't have the MVC runtimes installed on the target machine.
You can have a look to the folder C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4 of your server. You should find inside a few folders, including an "assemblies" one.
If not, you can download the runtimes from MS website. I THINK this one could work :
https://www.microsoft.com/en-us/download/details.aspx?id=30683&751be11f-ede8-5a0c-058c-2ee190a24fa6=True but you'll have to check.
You should also be able to install MVC from Web Platform Installer.
Alternatively, you can also avoid to install the runtimes if you do not wish or if you can't :
To make your application work without the requested runtimes on server, in the "References" folder of your visual studio, you can select all offending assemblies, and for each of them, set to "True" the "Copy local".
You will have to do this for the MVC dll, but probably for a few others, for example : System.Net.Http, System.Net.Http.Formatting.dll, System.Net.Http.WebRequest, System.Web.Http.dll, System.Web.Http.WebHost.dll, etc.
So it will maybe require a few tries (fortunately you just have to read the error message at startup to get the name of the "next" missing DLL).
There is another possible cause. I just had this same error today. Basically, I imported a helper project from one solution to another, and then I got this error, even though the only web project in the new solution is an old WebForm! No razor at all!! Eventually, I realized one files in the helper project had a little code for helping process MVC drop down lists, and the helper project had a reference to System.Web.MVC. That was not needed in the new solution, so deleting that one file & the reference to System.Web.MVC solved the problem.
I had the same issue, but could not fix it for 3 days. I tried deleting .vs directory, trying with Visual Studio 2017 and 2019, removing references but the error was here:
In the bin directory, somehow (probably from the batch scripts we are using to build MS solutions) System.Web.Mvc.dll was there, and apparently it was loaded when WebForms solutions was started. After deleting the whole bin/ directory the WebForms started ok.
One problem was that I could start the WebForms solution using IIS Express, but Local IIS, but that's probably another type of problem.
Add System.Web.WebPages.Deployment.dll, System.Web.WebPages.dll, System.Web.WebPages.Razor.dll manually to the References folder

FSharp.Core: Could not load file or assembly

I have the following error when attempting to run a test:
{System.IO.FileLoadException: Could not load file or assembly
'FSharp.Core, Version=3.3.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'FSharp.Core, Version=3.3.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' at
Register.RegisterResponse.__DebugDisplay()
Tests.dll
FSharp.Core: 3.1.2.5
Target F# runtime: 4.3.1.0
Target Framework: 4.6
Output type: Class Library
ManageAccount.dll
FSharp.Core: 3.1.2.5
Target F# runtime: 3.3.1.0
Target Framework: .NET Portable Subset (.Net Framework 4.5, ASP.Net Core 1.0, Windows 8)
Output type: Class Library
I then added the following app config to my test project:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<bindingRedirect oldVersion="3.1.2.5" newVersion="3.3.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
If I do need an app config, what value should my bindingRedirect be set to?
Try <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.1.0" />. That's what most F# projects seem to be doing for FSharp.Core. (Or newVersion="4.3.1.0", or even newVersion="4.4.0.0" if you upgrade to a newer FSharp.Core).
You should use the newest version (4.3.1.0 in this case) in bindingRedirect/newVersion, otherwise, you will probably get errors from code in Tests.dll assembly which relies on the newer version.
Alternatively you can update the reference in one of the assemblies (downgrade Tests.dll or upgrade ManageAccount.dll) so that they both use the same version.

Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

I have an MVC5 Web api project. I am getting following error after deployment,
Could not load file or assembly 'WebGrease, Version=1.5.1.25624,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040) File name: 'WebGrease,
Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
In My project I have following references,
System.Web.Mvc - 5.1.0.0
System.Web.Razor - 3.0.0.0
WebGrease - 1.6.5135.21930
Also I have included Following section in my Web.config file,
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
I have tried with following steps but still not working ,
Uninstall-Package Microsoft.AspNet.Web.Optimization
Uninstall-Package WebGrease
Install-Package Microsoft.AspNet.Web.Optimization
Update-Package WebGrease
I have referred many links on technical blogs but still getting the same error after deployment.
Can any one help me to find the solution?
Thanks
In my case the reason was in folders/configs hierarchy in an application. Try to check that binding redirect is in your root web config.
As an example:
/AppRoot
Web.config1
/Areas/SomeArea
Web.config2
Make sure that you have correct binding redirect in Web.config1.
Hope this helps.

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.
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.
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.
#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.
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.
Sometime, you will have mistake between
System.Web.WebPages.Razor
and
System.Web.Razor
Try look and check
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

Resources