首页 文章

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

提问于
浏览
21

我已经将.NET WebAPI应用程序(针对.NET 4.5.2编译并在本地运行)部署到Azure应用服务中 .

抛出的错误是

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

我已经检查过App服务的 bin 目录中的System.Web.Mvc.dll大小为505504字节 - 与我的本地System.Web.Mvc.dll大小相同,版本为4.0.40804.0,更改为2014- 09-25,在当地工作没有问题 . 我能说的唯一区别是我在本地安装了.NET 4.5.2,而不是像Azure那样安装4.6.1 .

我的Web.config中的条目是

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

但我已经尝试过了

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

这也不起作用 .

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

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

'/'应用程序中的服务器错误 . 无法加载文件或程序集“System.Web.Mvc”或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (来自HRESULT的异常:0x80131040)描述:在执行当前Web请求期间发生了未处理的异常 . 请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息 . 异常详细信息:System.IO.FileLoadException:无法加载文件或程序集“System.Web.Mvc”或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (来自HRESULT的异常:0x80131040)源错误:在执行当前Web请求期间生成了未处理的异常 . 可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息 . 程序集加载跟踪:以下信息有助于确定无法加载程序集“System.Web.Mvc”的原因 . 警告:装配绑定日志记录已关闭 . 要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1.注意:程序集绑定失败日志记录会导致一些性能损失 . 要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog] . 堆栈跟踪:[FileLoadException:无法加载文件或程序集'System.Web.Mvc'或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (来自HRESULT的异常:0x80131040)] [FileLoadException:无法加载文件或程序集'System.Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (来自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,RunCAslmbly 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&stackMa rk,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 [ConfigurationErrorsException:无法加载文件或程序集'System.Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (例外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 [HttpException(0x80004005):无法加载文件或装配'mly'System.Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (来自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版本信息: Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1055.0

1 回答

  • 30

    您可以在工具> Nuget包管理器>管理解决方案的NuGet包(VS2015)中检查“装配版本” . 检查解决方案中项目中使用的程序集版本并使用单个版本 .

相关问题