gpt4 book ai didi

c# - Postsharp OWIN 版本不匹配

转载 作者:太空狗 更新时间:2023-10-30 00:30:29 26 4
gpt4 key购买 nike

我在我的项目中使用 PostSharp 4.2.22.0 和 Owin 3.0.1。

编译时出现以下错误:

Unhandled exception (4.2.22.0, postsharp-net40-x86-srv.exe, CLR
4.0.30319.394271, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'microsoft.owin.security, version=2.1.0.0, culture=neutral, publickeytoken=31bf3856ad364e35'. [Version mismatch]

但是 PostSharp 与 Owin 有关系吗?为什么 Owin 版本对 PostSharp 很重要,这是两个完全不同的包。

最佳答案

此错误通常出现在引用旧版本程序集的项目中,该程序集在您的 web.config 文件中具有绑定(bind)重定向。我猜你的 web.config 中有这样的东西:

<dependentAssembly>
<assemblyIdentity name="microsoft.owin.security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
</dependentAssembly>

默认情况下,PostSharp 不处理 web.config/app.config 文件。通过将 PostSharpHostConfigurationFile MSBuild 属性设置为您的 web.config 文件的路径,可以强制 PostSharp 加载绑定(bind)重定向。

您可以通过将这些行添加到您的 csproj 文件来实现:

<PropertyGroup>
<PostSharpHostConfigurationFile>web.config</PostSharpHostConfigurationFile>
</PropertyGroup>

这种不便应该已经在 PostSharp 4.3 中解决了不设置 PostSharpHostConfigurationFile 属性。但目前 4.3 还不是稳定版本。

编辑:代码已更新(缺少结尾'>')

关于c# - Postsharp OWIN 版本不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35887328/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com