Postsharp OWIN Version Mismatch
Asked Answered
S

1

5

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.

Strychnine answered 9/3, 2016 at 9:14 Comment(1)
R
9

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 '>')

Recife answered 9/3, 2016 at 10:43 Comment(1)
I have property group already and the error still occursWoermer

© 2022 - 2024 — McMap. All rights reserved.