我在我的项目中使用了PostSharp 4.2.22.0和owin3.0.1。
当我编译时,我会得到以下错误:
未处理的异常(4.2.22.0,PostShart-net40-x86-srv.exe,CLR ) 4.0.30319.394271,版本):PostSharp.Sdk.CodeModel.AssemblyLoadException:找不到程序集'microsoft.owin.security,version=2.1.0.0,culture=neutral,publickeytoken=31bf3856ad364e35‘。版本失配
但是,PostSharp和Owin有关系吗?为什么自带版本对PostSharp很重要,这是两个完全不同的包。
发布于 2016-03-09 10:43:10
此错误通常出现在引用web.config文件中绑定重定向的程序集的旧版本的项目中。我猜你的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文件。PostSharp可以通过将PostSharpHostConfigurationFile MSBuild属性设置为web.config文件的路径来强制加载绑定重定向。
您可以将这些行添加到csproj文件中:
<PropertyGroup>
<PostSharpHostConfigurationFile>web.config</PostSharpHostConfigurationFile>
</PropertyGroup>在没有设置PostSharp 4.3属性的情况下,这种不便应该已经在PostSharpHostConfigurationFile中解决了。但是目前4.3还不是一个稳定的版本。
编辑:更新的代码(缺失的结尾'>')
https://stackoverflow.com/questions/35887328
复制相似问题