Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 防止运行时程序集绑定到旧程序集_Asp.net_Asp.net Mvc_Assemblybinding - Fatal编程技术网

Asp.net 防止运行时程序集绑定到旧程序集

Asp.net 防止运行时程序集绑定到旧程序集,asp.net,asp.net-mvc,assemblybinding,Asp.net,Asp.net Mvc,Assemblybinding,我有一个包含3个项目的解决方案: Solution.Web.Core-通用类 Solution.Web.Mvc-Mvc 4 Solution.Web.Api-Web Api 2又名运行ASP.NET 5.0(beta-1)程序集 我已经将WebApi设置为MVC应用程序的子应用程序(在IIS中),但是,我很难实现此项目的完全隔离 因为Solution.Web.Core对ASP.NET 4.0程序集有一些引用,如果我在Solution.Web.Api中添加对该项目的引用,我在运行时会遇到以下异常:

我有一个包含3个项目的解决方案:

Solution.Web.Core-通用类
Solution.Web.Mvc-Mvc 4
Solution.Web.Api-Web Api 2又名运行ASP.NET 5.0(beta-1)程序集

我已经将WebApi设置为MVC应用程序的子应用程序(在IIS中),但是,我很难实现此项目的完全隔离

因为
Solution.Web.Core
对ASP.NET 4.0程序集有一些引用,如果我在
Solution.Web.Api
中添加对该项目的引用,我在运行时会遇到以下异常:

无法加载文件或程序集“System.Net.Http.Formatting,Version=5.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100)

如何防止在
Solution.Web.Api
中发生此错误,以便我可以引用
Solution.Web.Core
,尽管它引用的是较旧的ASP.NET程序集版本


注意:由于错误是“
System.Net.Http.Formatting
或它的一个依赖项”,我真的不知道如何找出哪一个是确切的有问题的程序集。

我只是从MVC 5+Web Api 2开始解决了这个问题

然而,刚刚发现这似乎对我有用:

要使MVC 4项目能够很好地使用5.0测试版程序集(至少博客文章中的CORS程序集),请将web配置更改为以下内容:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:bcl="urn:schemas-microsoft-com:bcl">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
  </dependentAssembly>


从更改视图部分的Web.Config

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, **Version=5.0.0.0**, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>



您可以看看这个:谢谢。这似乎适用于.NET运行时。我的3个应用程序都运行.NET4.5。不同的是ASP.NET程序集。我认为尽管有一些设置(我一直认为是这样)允许您指定所要求的内容。
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, **Version=5.2.3.0**, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>