The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ForumJason (8) [Avatar] Offline
While working through the example on Caching in Chapter 4 (section 4.3), I ran into an issue with PostSharp and the default Web Forms application project in Visual Studio 2012 (this issue occurs whether targeting .NET 4.0 or .NET 4.5).

The default ASP.NET web forms project template creates a web.config with assembly binding redirects for several oauth assemblies. PostSharp 2.1 cannot work with assembly binding redirects. Fortunately, by the time this book hit the shelves (or at least when I received the book in the mail!), PostSharp 3.0+ had been released via NuGet and was also available on the PostSharp site.

PostSharp 3.0+ can work with assembly binding redirects, but an additional step must be taken for the ASP.NET project to build after adding PostSharp to the project. The .csproj file needs to be opened in a text editor, and the web.config needs to be removed from the Content ItemGroup, and put into a new ItemGroup like this:

<PostSharpHostConfigurationFile Include="Web.config" />

Then everything will work. I'm thinking that any project with assembly binding redirects will have an issue with PostSharp unless the above is done for either Web.config or App.config files.

See this post from PostSharp support for more information: (the issues mentioned by the original author appear to be resolved in the production release of PostSharp 3)
matthew.groves (46) [Avatar] Offline
Re: PostSharp in VS2012: Chapter 4 Fix
My code samples were written in Visual Studio 2010, so I did not run into this issue while writing the book. However, I've also done a lot of speaking and demos using Visual Studio 2012, and I haven't run into this problem either (the caching demo is one that I use most often), and I haven't had to take the additional step you describe.

But thanks for posting about it here, I appreciate it!