2017-10-12 20 views
6
Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

Server Error in '/api' Application. 

Could not load file or assembly 'System.Web.Helpers' 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.Helpers' 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.Helpers' could not be loaded. 


=== Pre-bind state information === 
LOG: DisplayName = System.Web.Helpers 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: System.Web.Helpers | Domain ID: 3 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///C:/source/TDMS/TDMS.WebServices/ 
LOG: Initial PrivatePath = C:\source\TDMS\TDMS.WebServices\bin 
Calling assembly : (Unknown). 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\source\TDMS\TDMS.WebServices\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: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/8f8ef96b/51bdcfc3/System.Web.Helpers.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/8f8ef96b/51bdcfc3/System.Web.Helpers/System.Web.Helpers.DLL. 
LOG: Attempting download of new URL file:///C:/source/TDMS/TDMS.WebServices/bin/System.Web.Helpers.DLL. 
LOG: Using application configuration file: C:\source\TDMS\TDMS.WebServices\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: Redirect found in application configuration file: 1.0.0.0 redirected to 3.0.0.0. 
LOG: Post-policy reference: System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/8f8ef96b/51bdcfc3/System.Web.Helpers.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/api/8f8ef96b/51bdcfc3/System.Web.Helpers/System.Web.Helpers.DLL. 
LOG: Attempting download of new URL file:///C:/source/TDMS/TDMS.WebServices/bin/System.Web.Helpers.DLL. 
WRN: Comparing the assembly name resulted in the mismatch: Major Version 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. 

Stack Trace: 


[FileLoadException: Could not load file or assembly 'System.Web.Helpers' 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 'System.Web.Helpers, 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.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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +234 
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +108 
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +25 
    System.Reflection.Assembly.Load(String assemblyString) +34 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49 

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Helpers, 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.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +772 
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259 
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +163 
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +230 
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +76 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +139 
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +176 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +882 

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Helpers, 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) +579 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712 

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

這發生在TDMS.WebServices項目中,該項目是.net 4.5 Web API 2.0。我們也有一個MVC5項目。無法加載文件或程序集'System.Web.Helpers'

從bin文件夾中刪除.dll並再次編譯修復它。重建會將DLL帶回並刪除它。

有些東西是注入system.web.helpers.dll到bin文件夾,我不知道是什麼造成它,但我懷疑它可能與MVC項目有關的System.Web.Helpers

更新:

這是新的錯誤我重做引用後得到:

Could not load file or assembly 'System.Web.Helpers' 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.Helpers' 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.Helpers' 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.Helpers' 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 'System.Web.Helpers, 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.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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +234 
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +108 
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +25 
    System.Reflection.Assembly.Load(String assemblyString) +34 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49 

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Helpers, 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.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +772 
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259 
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +163 
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +230 
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +76 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +139 
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +176 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +882 

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Helpers, 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) +579 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712 
+0

如果它,如果你從文件夾中刪除該DLL再次工作,這很可能是因爲它是從GAC加載的。你的一個項目是引用這個DLL,並且它在編譯時會將一個本地副本放入bin文件夾中,這會導致它中斷(bin文件夾具有更高的優先級)。檢查GAC以查看存儲的版本,然後再次編譯並檢查放入文件夾的版本。他們不一樣。 – JuanR

+0

這似乎是問題的發生,我該如何解決它?我不相信我可以將該副本更改爲本地MVC項目 – CuriousDeveloper

+0

您需要做的是參考正確的版本。哪一個更高? GAC還是本地參考? – JuanR

回答

0

你說得對,它正在從MVC簡稱。 System.Web.Helpers通常是您在NuGet上可以找到的包Microsoft.AspNet.WebPages的一部分。在某些運行時環境中,它安裝在GAC中並因此公開可用。

從控制檯的NuGet,運行

Update-Package Microsoft.AspNet.WebPages 

請確保您有在web.config中重定向:

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
</dependentAssembly> 
+0

它沒有發現任何Microsoft.AspNet.WebPages的更新,我確認web.config條目是確切的 – CuriousDeveloper

0
Add the reference of System.Web.Helpers.dll file to your project, 

and add below setting in web.config file 

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
</dependentAssembly> 
相關問題