【问题标题】:Sharing code between Xamarin forms and ASP.NET MVC 5 (.NET 4.6.1) projects在 Xamarin 表单和 ASP.NET MVC 5 (.NET 4.6.1) 项目之间共享代码
【发布时间】:2018-12-03 09:59:23
【问题描述】:

在 ASP.NET MVC 5 (.NET 4.6.1) 项目中,我已将旧的 PCL 项目用于与 Xamarin 项目共享代码,并使用新的 .NET 标准 2 项目(因为 Xamarin 项目现在是Xamarin 形成 3.2 项目)。

ASP.NET MVC 5 编译没有错误,但给出以下警告: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5):

警告 MSB3247:发现同一依赖程序集的不同版本之间存在冲突。

在 Visual Studio 中,双击此警告(或选择它并按 Enter)以修复冲突;否则,将以下绑定重定向添加到应用程序配置文件中的“运行时”节点:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="System.Collections.Concurrent" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
    </dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="System.Collections" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
    </dependentAssembly>
</assemblyBinding>

... assemblyBinding 节点列表继续。

解决方案是将每个列出的 assemblyBinding xml 节点添加到 web.config > configuration > runtime 部分吗?

参考文献

共享项目代码共享 https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/shared-projects?tabs=windows

共享代码概览 https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing

【问题讨论】:

  • 您是否尝试将 assemblyBinding xml 节点添加到 web.config > 配置 > 运行时部分?

标签: c# asp.net-mvc xamarin.forms


【解决方案1】:

我将列出的 52 个程序集添加到该部分,警告消失了。

Web.Config

<configuration>
 <runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="System.Collections.Concurrent" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
     </dependentAssembly>
     <dependentAssembly>
        <assemblyIdentity name="System.Collections" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
     </dependentAssembly>
  </assemblyBinding>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-08
    • 2019-03-29
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多