2013-05-28 13 views
28

Localmente - la mia MVC 4, asp.net, C# app funziona bene su IIS 8/Windows 8.Impossibile caricare il file o l'assembly 'System.Web.Mvc, Version = 3.0.0.0, problema Elmah.MVC

se distribuito a Windows Server 2008, ottengo questo errore:

Could not load file or assembly 'System.Web.Mvc, Version=3.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) 

e

[FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.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)] 
    Elmah.Mvc.Bootstrap.Initialize() +0 

[InvalidOperationException: The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=3.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) +12881963 
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12881672 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +240 
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +152 
    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 Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=3.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) +12881108 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297 

questo accade se si seleziona 'file Solo necessari per eseguire questa applicazione' dalle 'Articoli da distribuire' drop giù nelle proprietà del progetto/pacchetto/pubblichiamo noi b.

Se seleziono "tutti i file in questo progetto", funziona correttamente.

Immagino che Elmah sia dipendente da una versione precedente di MVC o qualcosa del genere - come posso risolvere questo problema senza dover caricare tutti i file?

Qual è il modo migliore per risolvere problemi come questo?

Grazie.

risposta

58

ho avuto questo problema esattamente lo stesso utilizzando MVC4 con Ninject costruito per .Net 4.5

Per risolvere questo ho dovuto aggiungere un'associazione reindirizzare al mio file web.config: (alla fine del file, basta prima del tag </configuration>)

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/> 
     </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35"/> 
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/> 
    </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

Questo costringe il server web da utilizzare System.Web.Mvc 4.0.0.0 invece di una versione precedente.

+1

la configurazione assemblyBinding per System.Web.Mvc ha funzionato per me! – EdmundYeung99

+2

ha funzionato anche per me :-) – Baconbeastnz

+1

funziona come un incantesimo per errore di rinnovo, grazie! –

0

Sei sicuro di utilizzare ASP.NET MVC (visualizza controller ecc.)? o la tua app Web utilizza esclusivamente WebAPI ASP.NET? In tal caso, installare solo il pacchetto NuMet ElMAH e non Elmah.MVC.

Per le sole app WebAPI ASP.NET raccomanderei il pacchetto Emah.Contrib.WebAPI. Questo pacchetto può anche essere installato tramite NuGet.

0

Nella pagina di errore che ho avuto questo:

LOG: reindirizzamento rilevato nel file di configurazione dell'applicazione: 5.1.0.0 sono stati dirottati verso 5.2.3.0.

Quindi ho dovuto modificare questa linea in web.config alla versione 5.1.0.0 e ha funzionato!

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.1.0.0" /> 
    <!--<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> Older line --> 
    </dependentAssembly> 

penso che questo sia dovuto ad un problema di versione quando ho scaricato il codice da TFS

Spero che questo aiuti

0

Aggiungi sottostante Codice in web.config:

<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" /> 
    </dependentAssembly> 
</assemblyBinding> 

Problemi correlati