Razor views: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception

10,689

Solution 1

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

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

Solution 2

I found as soon as I added log4net via NuGet to my application that while the error has not gone away, Intellisense works in the file.

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

Solution 3

The wrong project was selected in the Package Manager Console.... my stupid mistake. Guess I should have had more coffee before working on this.

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

Share:
10,689
Escobar5
Author by

Escobar5

Web developer

Updated on June 23, 2022

Comments

  • Escobar5
    Escobar5 almost 2 years

    I'm working in an Asp.net MVC 4 project in Visual Studio 2012, when I open a view I'm getting this error:

    ASP.NET runtime error: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: The type initializer for 'DotNetOpenAuth.Reporting' threw an exception.. C:\Users\escobar5\Desktop\WindowsAzure1\MvcWebRole1\Views\Shared_LoginPartial.cshtml

    So I lost intellisense because after that error every call to ViewBag or model says: "One or more types required to compile a dynamic expression cannot be found"

    I updated OAuth packages from Nuget but I'm still getting the error.

    The project runs fine, the problem is just with razor.

    This is a screenshot of the error for more detail:

    Error

    Any ideas?

    Thanks in advance

  • Andrew Arnott
    Andrew Arnott over 11 years
    What if you reload your solution after having added NuGet? Do you still get the error?
  • Dan Csharpster
    Dan Csharpster almost 10 years
    If all else fails, update it or turn it off and on again. Thanks! :-)