我已经四处寻找这个bug的解决方案,但是还没找到,甚至在SO上。我收到的警告是:
(0,0): warning CS1702: Assuming assembly reference 'Microsoft.Owin.Security.OAuth,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches
'Microsoft.Owin.Security.OAuth, Version=2.0.2.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy
Validation Complete
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
这就是我的Bin
目录:
这是packages.config
文件:
<packages>
<package id="EntityFramework" version="6.0.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="2.0.2" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Cookies" version="2.0.2" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="2.0.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
在我的web.config
文件中,运行时部分如下所示:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
您认为我需要做些什么才能摆脱这种警告?
感谢。
答案 0 :(得分:6)
您的项目文件可能仍在引用先前版本的程序集。
您可以通过选择项目中的References下的Microsoft.Owin.Security.OAuth引用并查看属性来快速检查;但我建议您也检查项目文件的内容,并检查该程序集的参考,例如:
<Reference Include="Microsoft.Owin.Security.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\..\packages\Microsoft.Owin.Security.OAuth.2.0.0\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
</Reference>
检查参考版本和HintPath版本是否符合预期。
如果你查看解决方案的Packages文件夹,你可能会发现仍有多个版本的Microsoft.Owin.Security.OAuth,这可能是一个线索。 (你可以重命名或删除你不想要的所有版本,看看会发生什么)。
如果仍然没有达到足够的目的,请打开构建日志记录详细信息,看看是否可以为您提供更多线索。
为此,在Visual Studio中转到工具&gt; 选项&gt; 项目和解决方案&gt; 构建并运行,并将 MSBuild项目构建日志文件详细程度更改为正常或详细。