Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postsharp OWIN Version Mismatch

I'm using PostSharp 4.2.22.0 and Owin 3.0.1 in my project.

When I compile I get the following error:

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]

But was does PostSharp have to do with Owin? Why is the Owin version important for PostSharp, these are two totally different packages.

like image 318
Pinzi Avatar asked Mar 09 '16 09:03

Pinzi


1 Answers

This error usually appears in a project referencing an older version of an assembly with a binding redirect in your web.config file. I guess you have something like this in your 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 doesn't process web.config/app.config files by default. PostSharp can be forced to load binding redirects by setting PostSharpHostConfigurationFile MSBuild property to the path of your web.config file.

You can do it by adding these lines to your csproj file:

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

This inconvenience should be already fixed in PostSharp 4.3 without setting PostSharpHostConfigurationFile property. But currently 4.3 is not a stable release yet.

Edit: Code updated (missing end '>')

like image 180
Jakub Linhart Avatar answered Sep 18 '22 19:09

Jakub Linhart