Razor view: the application start initialization method begins with the type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode throws an exception

I am working on an Asp.net MVC 4 project in Visual Studio 2012, when I open a view, I get this error:

ASP.NET runtime error: method of initializing start before starting. Start by type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: The type initializer for "DotNetOpenAuth.Reporting" made an exception. C: \ Users \ escobar5 \ Desktop \ WindowsAzure1 \ MvcWebRole1 \ Views \ Shared_LoginPartial.cshtml

So, I lost intellisense because after this error every call to the ViewBag or model says: "It is impossible to find one or more types needed to compile a dynamic expression"

I updated the OAuth packages from Nuget, but I still get the error.

The project works fine, the only problem is the razor.

This is a screenshot of the error for more details:

Error

Any ideas?

Thank you in advance

+4
source share
5 answers

I found the following explanation and updating DotNetOpenAuth.OAuth.Consumer with the nuget package manager solved the problem with the error.

https://groups.google.com/forum/?fromgroups=#!topic/dotnetopenid/js58kMaWvvo

+3
source

I found, as soon as I added log4net via NuGet to my application, that although the error did not disappear, Intellisense works in the file.

It looks like the Reporting DotNetOpenAuth module relies on the Logger class, which in turn relies on log4net.

+1
source

The wrong project was selected in the package manager console ... my stupid mistake. I think I should have had more coffee before working on this.

I solved this by going to the “Manage NuGet Package for Solution” and clicking “Manage” next to ASP.NET MVC 4, and then adding this package to the MVC4 project in the solution.

+1
source

If you have this line in your web.config

 <add key="webpages:Enabled" value="true" /> 

then remove it.

0
source

I had to follow these two steps to solve this problem.

  • Update the DotNetOpenAuth.OAuth.Consumer NuGet package. Magnus Karlsson's credit for this bit - see his answer for more information.
  • Remove the assembly binding for System.Web.Razor from the Web.Config file. This is from rana's answer .
 <dependentAssembly> <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> 
0
source

All Articles