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

时间:2016-05-24 09:04:54

标签: c# asp.net asp.net-mvc azure .net-assembly

我已将.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>

也不起作用。

如何为我的应用程序编辑该条目以查找System.Web.Mvc.dll?

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

  

&#39; /&#39;中的服务器错误应用

     

无法加载文件或程序集&System; Web.Mvc&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)

     

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

     

异常详细信息:System.IO.FileLoadException:无法加载文件或程序集&System; Web.Mvc&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)

     

来源错误:

     

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

     

程序集加载跟踪:以下信息有助于确定程序集&System; Web.Mvc&#39;无法加载。

     

警告:装配绑定日志记录已关闭。   要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1。   注意:程序集绑定失败日志记录会导致一些性能损失。   要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]。

     

堆栈追踪:

     

[FileLoadException:无法加载文件或程序集&#39; System.Web.Mvc&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)]

     

[FileLoadException:无法加载文件或程序集&#39; System.Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)]      System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&amp; stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0      System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&amp; stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+36      System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&amp; stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+152      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&amp; stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)+77      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&amp; stackMark,Boolean forIntrospection)+21      System.Reflection.Assembly.Load(String assemblyString)+28      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+38

     

[ConfigurationErrorsException:无法加载文件或程序集&#39; System.Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (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&amp; 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):无法加载文件或程序集&System; Web.Mvc,Version = 4.0.40804.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35&#39;或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (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

2 个答案:

答案 0 :(得分:33)

您可以检查&#34;装配版本&#34;在工具&gt; Nuget包管理器&gt;管理解决方案的NuGet包(VS2015)。检查解决方案和项目中项目中使用的程序集版本。使用单一版本。

答案 1 :(得分:0)

关于System.Web.Mvc的版本,我有相同的错误。

就我而言,项目之间没有NuGet软件包不一致,但是我的Views文件夹中有一个web.config文件,其内容如下:

LinearLayout

更改此版本号以匹配当前安装的NuGet软件包即可解决此问题。

相关问题