“定位程序集的清单定义与程序集引用不匹配”

时间:2021-09-22 03:03:46

I have deployed an .NET WebAPI app (compiled against .NET 4.5.2, and running locally) into an Azure App Service.

我已经将一个。net WebAPI应用(基于。net 4.5.2编译并在本地运行)部署到一个Azure应用服务中。

The error thrown there is

这里抛出的错误是

Could not load file or assembly 'System.Web.Mvc, Version=4.0.40804.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

无法加载文件或程序集的System.Web。Mvc, Version=4.0.40804.0, Culture=中性,PublicKeyToken=31bf3856ad364e35'或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。

I have checked that the System.Web.Mvc.dll in the App service's bin directory has a size of 505504 bytes - the very same size as my local System.Web.Mvc.dll, which is version 4.0.40804.0, changed 2014-09-25, and working locally without issue. The only difference I can tell is that I have .NET 4.5.2 installed locally, not 4.6.1, like Azure does.

我检查过System.Web.Mvc。在应用程序服务的bin目录中,dll的大小为505504个字节——与我的本地系统的大小相同。dll,即4.0.40804.0版本,修改了2014-09-25,并且在本地工作没有问题。唯一的区别是,我在本地安装了。net 4.5.2,而不是像Azure那样安装了4.6.1。

The entry in my Web.config is

我的网络入口。配置是

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="4.0.40804.0" />
  </dependentAssembly>

but I have already tried

但我已经试过了

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

which doesn't work either.

这并不奏效。

How do I have to edit that entry for my application to find the System.Web.Mvc.dll?

如何为应用程序编辑条目以找到System.Web.Mvc.dll?

For reference, the full error message is:

作为参考,完整的错误消息是:

Server Error in '/' Application.

“/”应用程序中的服务器错误。

Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

无法加载文件或程序集的System.Web。Mvc或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(从HRESULT例外:0 x80131040)

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.

描述:在执行当前web请求期间发生了一个未处理的异常。请查看堆栈跟踪,以获得关于错误的更多信息,以及错误起源于代码的何处。

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

异常详细信息:先。FileLoadException:无法加载文件或程序集的System.Web。Mvc或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(从HRESULT例外:0 x80131040)

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.

在执行当前web请求期间生成了一个未处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪进行标识。

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc' could not be loaded.

程序集负载跟踪:以下信息有助于确定程序集的System.Web的原因。无法加载Mvc。

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].

关闭程序集绑定日志记录。要启用程序集绑定失败日志记录,请设置注册表值[HKLM\软件\Microsoft\Fusion!字EnableLog]()1。注意:与程序集绑定失败日志记录相关的性能损失。要关闭此功能,请删除注册表值[HKLM\软件\Microsoft\Fusion!EnableLog]。

Stack Trace:

堆栈跟踪:

[FileLoadException: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException:无法加载文件或程序集的System.Web。Mvc或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(从HRESULT例外:0 x80131040)]

[FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=4.0.40804.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.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.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[FileLoadException:无法加载文件或程序集的System.Web。Mvc, Version=4.0.40804.0, Culture=中性,PublicKeyToken=31bf3856ad364e35'或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(HRESULT: 0x80131040的除外)]System.Reflection.RuntimeAssembly_nLoad(程序集名文件名,字符串代码库,证据集安全,运行时装配定位提示,stackcrawlmark&stackmark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forintroinspection, Boolean securitycheck) +0 System.Reflection.RuntimeAssembly。nLoad(程序集名文件名,字符串代码库,证据集安全,运行时程序集定位提示,stackcrawlmark&stackmark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forintroinspection, Boolean securitycheck) +36 System.Reflection.RuntimeAssembly。InternalLoadAssemblyName(assembly yname assembly yref, Evidence assemblySecurity, RuntimeAssembly reqAssembly, stackcrawlmark&stackmark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean securitycheck) +152 System.Reflection.RuntimeAssembly。内部负载(字符串装配字符串、证据装配安全性、stackcrawlmark&stackmark、IntPtr pPrivHostBinder、布尔自省)+77 System.Reflection.RuntimeAssembly。内部负载(字符串装配字符串、证据装配安全性、stackcrawlmark&stackmark、布尔自省)+21 System.Reflection.Assembly。负载(字符串assemblyString)+ 28 System.Web.Configuration.CompilationSection。loadassembly助手(String assembly yname, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Mvc, Version=4.0.40804.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) +738 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290 System.Web.Compilation.BuildManager.ExecutePreAppStart() +157 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[ConfigurationErrorsException:无法加载文件或程序集的System.Web。Mvc, Version=4.0.40804.0, Culture=中性,PublicKeyToken=31bf3856ad364e35'或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(HRESULT: 0x80131040的异常)]system . web . configuration . compile ationsection。loadassembly助手(String assembly yname, Boolean starDirective) +738 system . web . configuration . compile . compile ationsection.loadallassemesfromappdomainbindirectory () +217 system . web.configurationationsection。LoadAssembly System.Web.Compilation.BuildManager(AssemblyInfo ai)+ 130。“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”调用prestartinitmethods (String preStartInitListPath, Boolean& isrefassembly装载)+290 system . web . compile . build . manager . executeappstart () +157 system . web . host . hostingenvironment。初始化(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, hostingenvironment参数hostingParameters, PolicyLevel PolicyLevel, Exception appDomainCreationException) +531。

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Mvc, Version=4.0.40804.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) +9947380 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

[HttpException (0x80004005):无法加载文件或程序集的System.Web。Mvc, Version=4.0.40804.0, Culture=中性,PublicKeyToken=31bf3856ad364e35'或它的一个依赖项。定位程序集的清单定义与程序集引用不匹配。(HRESULT: 0x80131040的除外)]System.Web.HttpRuntime。FirstRequestInit(HttpContext上下文)+ 9947380 System.Web.HttpRuntime。+ 101 System.Web.HttpRuntime EnsureFirstRequestInit(HttpContext上下文)。ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext) +261

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

版本信息:Microsoft .NET Framework版本:4.0.30319;ASP。净版:4.6.1055.0

1 个解决方案

#1


26  

You may check "assembly versions" in Tools > Nuget Package Manager > Manage NuGet Packages for Solution (VS2015). Check versions of assemblies used in your projects in solution & use single version.

您可以查看工具> Nuget包管理器>中的“汇编版本”来管理解决方案的Nuget包(VS2015)。检查解决方案中项目中使用的程序集的版本,并使用单个版本。

#1


26  

You may check "assembly versions" in Tools > Nuget Package Manager > Manage NuGet Packages for Solution (VS2015). Check versions of assemblies used in your projects in solution & use single version.

您可以查看工具> Nuget包管理器>中的“汇编版本”来管理解决方案的Nuget包(VS2015)。检查解决方案中项目中使用的程序集的版本,并使用单个版本。