Konnte nicht geladen, Datei oder assembly 'System.Web.Webseiten.Razor'?
Ich habe eine MVC5 Application, die ich versuche zu veröffentlichen, um Microsoft Azure Webhosting. Wenn ich eine Anwendung ausführen, die auf meinem localhost funktioniert alles wie vorgesehen. Allerdings, wenn ich veröffentlichen auf Azure und versuchen, laden Sie die host-domain, erhalte ich die folgende Fehlermeldung:
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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)
.
Schaue ich in mein Web.Config-Dateien, ich habe Folgendes:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
Wenn das, was ich bin Zusammenkunft die Fehlermeldung ist korrekt, entweder meinen Antrag oder eine Komponente ist stattdessen sucht Version 2.0.0.0
statt 3.0.0.0
, aber ich habe keine Ahnung, was/die die das Problem verursachen können.
Hat sonst noch jemand Probleme beim veröffentlichen auf Azure?
BEARBEITEN:
Vorgeschlagen von trailmax
ich durchgeführt Add-BindingRedirect
im Paket-Manager-Konsole, die zu einer der folgenden:
PM> Add-BindingRedirect
Name OldVersion NewVersion
-------------- ------------ -------------
System.Web.Mvc 0.0.0.0-5.1.0.0 5.1.0.0
System.Web.WebPages 0.0.0.0-3.0.0.0 3.0.0.0
Dann habe ich mir localhost zu überprüfen, war noch alles in Ordnung (check) und versucht, die Veröffentlichung einmal mehr zu Azure. Immer noch das gleiche Problem :/
Hier ist die vollständige Aufschlüsselung:
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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)
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 'System.Web.WebPages.Razor, Version=2.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)
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.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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 'System.Web.WebPages.Razor, Version=2.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)]
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.WebPages.Razor, Version=2.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).]
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 Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
EDIT2:
Korrektur, die Hauptwurzel Web.config
Datei wurde geändert von Add-BindingRedirect
. Erhält immer noch das gleiche Problem auf veröffentlichen.
<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>
</assemblyBinding>
</runtime>
InformationsquelleAutor Analytic Lunatic | 2014-07-21
Du musst angemeldet sein, um einen Kommentar abzugeben.
Einer Ihrer Komponenten abhängig v2, daher die Frage. Müssen Sie bindungsumleitung in
web.config
für die Montage auf Punkt v3.Können Sie nuget-Konsole mit dem Befehl
Falls das tool nicht abholen version mismatch, können Sie es manuell hinzufügen, um
web.config
:Einer der Wege, um herauszufinden, welche Komponente hängt davon ab, ältere version verwenden, können Sie eine Abhängigkeit tracker-tool. Die, die ich in der Vergangenheit verwendet habe heißt CheckAsm. Die Kostenlose version ist gut genug für ein oder zwei mal verwenden.
Ich fügte hinzu, die manuelle Umleitung, wie Sie vorgeschlagen, indem die <runtime> und alles, was zwischen nur nach dem <configuration> in meiner Datei. Wenn ich jetzt die Anwendung ausführen (localhost) err ist auf
Parser Error Message: Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.
das war nicht der genaue code einfügen, mehr wie zeigt Struktur, wo Sie brauchen, um verbindliche umleiten. Entfernen
<configuration>
um kopieren-einfügen-code, finden<runtime>
Abschnitt Ihrerweb.config
und setzen<assemblyBinding>
Abschnitt innerhalb<runtime>
. Es sei denn, Sie haben bereits<assemblyBinding>
- in diesem Fall nur hinzufügen<dependentAssembly>
Abschnitt.Danke. Ich habe meine
web.config
- Dateien und nicht eine<runtime>
Abschnitt in jedem von Ihnen (warum ging ich mit der Struktur minus<configuration>
..?Wenn Sie
Add-BindingRedirect
es erschaffen haben sollruntime
undassemblyBinding
Abschnitte mit umgeleiteten Baugruppen fürSystem.Web.Mvc
undSystem.Web.WebPages
. Sind Sie auf der Suche auf die richtige Datei? Weiterleitung Baugruppen sollten nur inweb.config
im Stammverzeichnis der Website.InformationsquelleAutor trailmax
In meinem Fall, die Bindung Umleitung Abschnitt enthielt eine Umleitung für das System.Web.Webseiten.- Bereitstellung Baugruppe selbst, wie das ist:
Nach entfernen dieser Abschnitt, veröffentlichen auf Azure erfolgreich war.
InformationsquelleAutor Bijleveld