IIS: Microsoft.Web.WebPages.OAuth вызывает устаревший пакет Razor, вызывает сбой приложения

1

Недавно я обновил свой проект с Mvc 3 до Mvc 5, и мы пытаемся опубликовать приложение на сервере IIS, чтобы мы могли его протестировать. Но у нас есть неприятный крах, который всегда происходит, и я не знаю, что его провоцирует и как его исправить.

Здесь трассировка стека:

Server Error in '/' Application.

Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
  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.FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

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.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.



=== Pre-bind state information ===
LOG: DisplayName = System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\bin
Calling assembly : System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.



Stack Trace: 



[FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection'1 methods, Func'1 setHostingEnvironmentCultures) +12969195
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection'1 methods) +12968904
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +280
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12968244
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12807949




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446 

Так что меня озадачивает то, что у нас больше нет System.Web.Razor. Скорее, у нас есть System.Web.Razor версия 3.0.0.0. Тем не менее, я сделал все, что было предложено в этой ссылке о том, как обновить с mvc3 до mvc4, и все мои пакеты обновлены.

Я даже пытался удалить пакет Microsoft.Web.WebPages.OAuth, чтобы убедиться, что это было причиной, но он более устойчив, чем таракан, и я не смог его удалить, не имея приложения, которое больше не компилировалось. Мне нужна помощь в разрешении этого случая, единственным моим вариантом было бы попытаться создать новое приложение и перезагрузить все, что очень долго и утомительно.

  • 0
    Поскольку вы уже добавили перенаправления сборок в web.config, и у вас это не сработало, похоже, что вы пытаетесь создать новое приложение для сравнения 2 - это хороший план.
  • 0
    Я хотел бы изучить все возможности, прежде чем перейти к такой крайности, особенно с учетом того, что обе dll являются современными, но Microsoft.Web.WebPages.OAuth относится только к старой dll ...
Показать ещё 5 комментариев
Теги:
razor
asp.net-mvc-4

2 ответа

1
Лучший ответ

Наконец, пришлось переустановить все.

По этой ссылке: Шаблон веб-приложения ASP.NET MVC 5 на VS 2012? , Я реинтегрировал все, переделал пакеты, и теперь это работает.

1

это может быть связано с несоответствием сборки. вам нужно обновить файл Views\Web.config с обновленной сборкой для бритвы.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню