【问题标题】:Can I use two versions of an assembly on the same ASP.NET MVC website?我可以在同一个 ASP.NET MVC 网站上使用两个版本的程序集吗?
【发布时间】:2013-12-24 00:54:38
【问题描述】:

我有一个使用 System.Web.Http.dll 版本 4 的 Umbraco 7.0 网站,我想集成一个使用 System.Web.Http.dll 版本 5 的 Web API 2 项目。

我已经阅读并尝试了很多方法来尝试让两个 dll 正常工作,但现在我不太确定这是否可行。

我期望的工作是将 dll 放在单独的文件夹中,并在 web.config 中引用它们。我尝试过的事情:

<configuration>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="bin;c:\umbraco\dll\folder;c:\webapi\dll\folder"/>
    </assemblyBinding>
    </runtime>
</configuration>

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http"  culture="neutral" publicKeyToken="31bf3856ad364e35"/>
    <codeBase version="4.0.0.0" href="FILE:c:\umbraco\dll\folder\System.Web.Http.dll"/>
</dependentAssembly>

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http"  culture="neutral" publicKeyToken="31bf3856ad364e35"/>
    <codeBase version="5.0.0.0" href="FILE:c:\webapi\dll\folder\System.Web.Http.dll"/>
</dependentAssembly>

我不断得到以下两个之一:

CS0012: The type 'System.Web.Http.HttpConfiguration' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

CS1705: Assembly 'WebApi2Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

【问题讨论】:

标签: c# .net asp.net-mvc dll


【解决方案1】:

这是不可能的。 appdomain 将加载其中一个 dll,然后尝试上传另一个,但您会收到程序集不匹配错误。

【讨论】:

    猜你喜欢
    • 2015-06-29
    • 2018-05-04
    • 1970-01-01
    • 2010-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-03
    • 1970-01-01
    相关资源
    最近更新 更多