I am facing problem very similar to problem what we have in this question.
We have a standard MVC5 application that we have deployed on Windows Azure using webrole.
After deploying I can see below error message on visual studio 'Microsoft Azure Activity Log' window
Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation.
I can see below error message on management console.
Restarting (Role has encountered an error and has stopped. Sites were deployed. [2014-10-22T04:46:57Z])
I found below error message in event viewer. ( inside VM )
The description for Event ID 1007 from source Windows Azure Runtime 2.4.0.0 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
2232
WaIISHost
Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=4.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)
File name: 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
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].
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
the message resource is present but the message is not found in the string/message table
I don't know why its referring to version 4.0.0.0
My section of web.config file looks like this.
<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.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Your web.config controls w3wp.exe, but your callstack indicates that you are crashing in WaIISHost.exe. You have a couple options:
Why are you referencing System.Web.Mvc in your role entry point DLL (typically WebRole.cs)? If you can refactor this part of your code then you don't have to worry about loading this DLL and all of it's dependencies in your WaIISHost process.
Create an app.config with the same binding redirect you have in your web.config.
I got the solution for this problem. I found location of WaIISHost.exe and modify existing WaIISHost.exe.config file by adding binding redirect statements to it.
You can find this file under 'E:\base\x64'
I had this problem with version 5.1 and I had to set the MVC dll copytolocal=true. I believe it is related to the previous MVC security update. This is Microsoft's brute force away of insisting you update MVC.
Related
I have two projects in my solution, project1 and project2.
Project2 tends to self host with Owin.
I have enable CORS using Microsoft.Owin.Cors package.
Both project have Microsoft.OWIN 3.0.1 and Microsoft.AspNet.Cors
5.2.3.
Then, I copy my project2.exe to project1's debug folder and call
prorject2.exe from project1.
Then, then the exception box rises when trying to call project2.exe.
The message is that it requires System.Web.Cors version 5.0.0.0
assembly.
When I downgrade the Microsoft.AspNet.Cors to 5.0.0.0, it
again says it requires Microsoft.Owin version 2.0.2.
Why does this occur and how do I fix this version conflict? Both the projects is built under .Net Framewrok 4.5.2.
In order to resolve to conflict you must tell your code which version of OWIN to use. this can be done from your application's app.config.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
We have recently upgraded our MVC3 application to MVC5 (rather, we are attempting to do so now).
The application runs successfully on some machines, but not mine. It also won't run on the web server.
I have compared the versions of the System.Web.* dlls with those on the working machine and they appear to be the same.
I have also followed the fixes from the other threads I found, with to no avail. I will have to search again to find those that I tried, but here is the first one that I remember.
Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()'
What else would I need to change/update to prevent this problem?
Here is the error and stack trace:
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.MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.
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.
Stack Trace:
[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.]
System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +96
System.Web.WebPages.Administration.PreApplicationStartCode.Start() +41
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931916
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
UPDATE
Here is some info from my web.config
<compilation debug="true" targetFramework="4.5.2">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
...
</assemblies>
</compilation>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Routing" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<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="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
For me this happened when i went to VS 2015. It seems that the system.web.webpages.administration.dll was remaining in the bin folder and this caused a problem. this happened when I upgraded some NUGet packages. I am unsure to which one. I deleted the .dll and this fixed the issue for me. I noticed when i reinstalled the web helpers it seemed to come back, so maybe that is the offending package?
Edit: I wanted to add that I did not find the dependency in the vbproj file in my case. I could find nowhere that my project used this .dll but all the same it seems to load up.
Just incase if anyone faced this issue when publishing the app to Azure app service
Go to settings in the publishing profile
check the checkbox "Remove additional files at destination"
Try this:
comment below two lines in site.csproj file
<!--<None Iclude="_bin_deployableAssemblies\System.Web.WebPages.Administration.dll" />-->
<Content Include="App_Data\XmlDocument.xml" />
for me, I solved it by removing the reference for System.Web.Administration.dll in the project. This site, pointed me to the right direction https://codedump.io/share/d2rw80bGmlwc/1/methodaccessexception-inside-systemwebwebpages-migrating-mvc-3-to-mvc-5
I also ran into this issue. Even after removing the System.Web.Administration.dll from the website\bin directory, I was then getting a permissions error on those DLLs.
I closed visual studio, and re-opened in Administrator mode (I must have missed this when opening the solution), loaded up the same solution, and then was able to rebuild successfully.
I had the same issue and after searching all over the place and trying different options which did not work, I simply deleted all the files from bin\ and published the site again and it worked. Many people pointed to certain .dll files but the easiest solution was what I did and the site is back up and running.
error-pic
Not a precise solution to this - but in case it's helpful - had similar error:
Attempt by security transparent method 'System.Web.WebPages.WebPageRoute.<.cctor>b__0()' to access security critical method 'System.Web.WebPages.Deployment.WebPagesDeployment.IsExplicitlyDisabled(System.String)' failed.
The cause was around the following binaries:
\bin\System.Web.Razor.dll
\bin\System.Web.WebPages.dll
\bin\System.Web.WebPages.Razor.dll
I found a version of the same asp.net site that was working (for example a QA/STAGE site - or another dev machine where this works).
Copied the binaries from here - this cleared the error.
Again - not a solution - but it might help you find the cause. Check your project references.
When I run my app on the emulator for iOS it works fine. When I run it on a device the first call to HttpClient fails. My class containing the HttpClient calls is in a PCL. It looks like an instance of this bug.
However, the documented workarounds of adding the following to your iOS project app.config does not work for me (the system.net.http addition);
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
......
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
EDIT:
With this in my app.config, the following method successfully retrieves the data from the server, but fails to read it. The bottom line containing ReadAsAsync(..) fails and throws an exception. The exception is 'null' and nothing is output to the terminal either. It works fine on the emulator, but not the device.
public async Task<List<ExternalLoginViewModel>> GetExternalLoginsAsync()
{
using (var client = GetNewHttpClient(false))
{
client.DefaultRequestHeaders.Remove("Authorization");
var response = await client.GetAsync("api/account/externalLogins?returnUrl=/&generateState=true");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsAsync<List<ExternalLoginViewModel>>();
}
}
Your assembly binding redirection is wrong. Your iOS project should have an app.config file with this content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
The reason for the redirect is that the Microsoft.Net.HttpClient packages contains the System.Net.HttpClient namespace but that already exists on iOS and Android (with slightly different features even). At runtime it will resolve to the wrong assembly and not use the (Xamarin-)native iOS one.
You can find a demo project for iOS, Android and WP8 based on HttpClient in a PCL at my Github repo.
This was resolved by uninstalling the "Microsoft HTTP Client Libraries" nuget package from both the PCL and the iOS project. Then reinstalling on both. The iOS project has references now to 'System.Net.Http.Extensions' and to 'System.Net.Http.Primatives' but does not contain one to 'System.Net.Http'. The following binding redirect is used in the app.config file in the iOS project as well;
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
After moving my Azure web app to SDK 2.1 I have started getting the
type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.
error message. The same is working fine in the local environment but gives above error on Azure.
My web.config already has following entries:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.StorageClient"
publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.7.0.0" newVersion="1.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime"
publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Diagnostics"
publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
and
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
still it's not working in live Azure. Can someone please help me out?
It is possible that you may be running different Windows Azure DLLs than the ones installed (by default) on live Azure instance roles. Right click the Microsoft.WindowsAzure.[any] references in your project and check the version number in the Properties window and try to match them with the version numbers in your config files.
The project runs fine locally, its only when published I get the following error:
Could not load file or assembly 'System.Web.Razor' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Having spent the last few hours googling the problem seems to be that a nuget package I added to the project references razor 1 and overwrote my razor 2 dll. I've tried copying the razor 2.0.0.0 dll into refernces instead of 1 but the error persists. This is where the conflict is shown in the detailed build output:
There was a conflict between "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
1> "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
1> References which depend on "System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll].
1> C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll
1> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll".
1> System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1> References which depend on "System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Users\Jack\SkyDrive\LessonUp.Current\packages\RazorEngine.3.0.8\lib\net40\System.Web.Razor.dll].
1> C:\Users\Jack\SkyDrive\LessonUp.Current\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll
1> Project file item includes which caused reference "C:\Users\Jack\SkyDrive\LessonUp.Current\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll".
1> System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1> Recaptcha
From there it continues to list other packages depending on razor 2.
The packages I added to the project were: Recaptcha, Recaptcha.mvcModel and Postal.
Does anyone have an idea what steps I can take to resolve this?
Let me know if there is any more information I can give that might lead to a solution.
Make sure the 2.0 dll is referenced and copy local = true, then try adding an assembly binding redirect in the web.config:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding?
I had the same problem with Postal 0.8.0 in a MVC4 project. When you install Postal with NuGet it replaces System.Web.Razor 2.0 with System.Web.Razor 1.0. I had to delete the reference to System.Web.Razor 1.0 and then added back in System.Web.Razor 2.0. You have to additionally set Copy Local to True in the Properties for System.Web.Razor and the of course rebuild the project. Once I did that VS2012 copied the System.Web.Razor.dll to the deployed bin directory and the problem cleared.
Postal also adds these dependency's to the web.config. I removed them and it still works properly.
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RazorEngine" publicKeyToken="9ee697374c7e744a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.8.0" newVersion="3.0.8.0" />
</dependentAssembly>
Finally got this sorted, downloaded razor2.0 again from nuget. Seemed to sort the webconfig and fix dependency errors. Is up and running on azure not without any problem.
Check your project file and web.config to see if they've been munged by a NuGet package. A known problem child is postal 0.8.0. It pulls in as a dependency a beta version of RazorVersion (even if you've filtered to show stable only). Even if you update RazorVersion to the latest version, which is stable, your project file ends up referencing System.Web.Razor version 1, and your web.config has incorrect runtime assembly bindings.
To fix, do a diff on your project file and web.config against those of a fresh, empty MVC 4 project. Then copy over the correct Reference element for System.Web.Razor from the original project file. In web.config, delete the dependentAssembly element for System.Web.Razor.
Here's the TLDD (too lazy, didn't diff) text for your project file. Hopefully, by the time this snippet is out of date, the underlying cause(s) will be fixed.
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.20715.0\lib\net40\System.Web.Razor.dll</HintPath>
</Reference>
(Unfortunately, you can't fix this by uninstalling and reinstalling with NuGet, because you'd have to first uninstall the offending dependent package such as postal, which will re-break things when you re-install it.)
Original..
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
For some reason newVersion attribute was set to 2.0.0.0 version while dll was of 3.0.0.0
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
Than it worked