I just upgraded a project from VS2008/.NET 3.5/PostSharp 1.5 to VS2010/.NET4.0/PostSharp 2.0.
Now, when running the unit tests for the system I get hundereds exceptions in the form of:
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at COMPANY.Data.NHibernate.BaseRepository.c__Binding`1.Invoke(Object& instance, Arguments arguments, Object aspectArgs) at PostSharp.Aspects.Internals.MethodInterceptionArgsImpl.Proceed() at COMPANY.Aop.TransactionAspectAttribute.OnInvoke(MethodInterceptionArgs context) in C:\COMPANY\Code\COMPANY-NET4.0\Core\Aop\TransactionAspectAttribute.cs:line 68 at COMPANY.Data.NHibernate.BaseRepository.Save[T](T scoreBigModel) in C:\COMPANY\Code\COMPANY-NET4.0\Core\DataAccess\NHibernate\BaseRepository.cs:line 102 at COMPANY.UnitTests.DataAccess.NHibernate.when_saving_a_canonical_term.<.ctor>b__5() in C:\COMPANY\Code\COMPANY-NET4.0\UnitTests\DataAccess\NHibernate\CanonicalTermRepositorySpecs.cs:line 29 at Machine.Specifications.Utility.RandomExtensionMethods.InvokeIfNotNull(Because because) at Machine.Specifications.Model.Context.EstablishContext()
When I run peverify.exe on the assembly, I see hundreds of errors in the following form. Always seems to be issues with generic methods:
[IL]: Error: [C:\COMPANY\Code\COMPANY-NET4.0\Core\bin\Debug\COMPANY.Core.dll : COMPANY.Data.NHibernate.ActivationRepository+c__Binding::Invoke][offset 0x0000008D][found ref 'PostSharp.Aspects.Internals.MethodBinding'][expected ref 'PostSharp.Aspects.Internals.MethodBinding`1[COMPANY.Models.Activation]'] Unexpected type on the stack.
[IL]: Error: [C:\COMPANY\Code\COMPANY-NET4.0\Core\bin\Debug\COMPANY.Core.dll : COMPANY.Data.NHibernate.ActivationRepository+c__Binding::Invoke][offset 0x00000056][found ref 'PostSharp.Aspects.Internals.MethodBinding`1[COMPANY.Models.Activation]'][expected ref 'PostSharp.Aspects.Internals.MethodBinding'] Unexpected type on the stack.
I am running the latest release of PostSharp 2.0 RC.