Не удалось загрузить файл или сборку. После остановки запустите службу приложений Azure. - PullRequest
0 голосов
/ 13 февраля 2019

Я публикую веб-приложение ASP.NET MVC в службе приложений Azure.Он запускает поиск, когда он изначально опубликован.Если я отключаю службу приложения, а затем запускаю ее снова через несколько часов, я получаю эту ошибку при попытке открыть сайт в браузере, я не могу понять, почему он работает, пока приложение не будет выключено и снова включено:

Server Error in '/' Application.
Could not load file or assembly 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 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 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 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 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 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].


Stack Trace:


[FileLoadException: Could not load file or assembly 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'RazorEngine, Version=3.7.2.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
    System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.Assembly.Load(AssemblyName assemblyRef) +36
   MyProject.Core.Plugins.PluginManager.PerformFileDeploy(FileInfo plug) +460
   MyProject.Core.Plugins.PluginManager.Initialize() +3201

 [Exception: Could not load file or assembly 'RazorEngine, Version=3.7.2.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    Could not load file or assembly 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   MyProject.Core.Plugins.PluginManager.Initialize() +4423

[InvalidOperationException: The pre-application start initialization method Initialize on type MyProject.Core.Plugins.PluginManager threw an exception with the following error message:     Could not load file or assembly 'RazorEngine, Version=3.7.2.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Could not load file or assembly 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 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(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +615         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) +549


[HttpException (0x80004005): The pre-application start initialization method Initialize on type MyProject.Core.Plugins.PluginManager threw an exception with the following error message: Could not load file or assembly 'RazorEngine, Version=3.7.2.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Could not load file or assembly 'RazorEngine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 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) +10075124
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254


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

Я вижу, что это как-то связано с сборкой MyProject.Core.Plugins.PluginManager, которая его вызывает.Это проект в моем решении, который используется веб-приложением.Иногда, когда я отлаживаю локально и изменяю страницу бритвы, я получаю сообщение об ошибке, связанное с этим.Это не очень специфично и не происходит последовательно.Я могу исправить ситуацию в своей локальной среде разработки, очистив решение, а затем перестроить.Ошибка, которую я разместил в этой статье, согласуется с каждым разом, когда я затем выключаю службу приложения.

Этот пост рассказывает об определенной ошибке, но это старый пост и рассказывает о GAC, который я не использую в Azure или в моей среде разработки.

1 Ответ

0 голосов
/ 14 февраля 2019

Мне пришлось изменить версию RazorEngine в проекте пакета plugin.json на ту же версию, которая используется веб-проектом.

<package id="RazorEngine" version="3.4.1" targetFramework="net45" />

до

<package id="RazorEngine" version="3.7.2" targetFramework="net45" />

Затем я запустил Update-Package -Reinstall RazorEngine

Этот пост направил меня в правильном направлении.Комментарий Джорджа Чена помог бы, но я нашел решение до того, как он написал.

...