PostSharp 2.0 BadImageFormatException
We have an application here which is using postsharp to wrap certain methods within a transaction aspect derived from MethodInterceptionAspect. We use NHibernate 2.0 as an ORM for the application. Ther开发者_运维百科e is a failure within this block of code,
public override void OnInvoke(MethodInterceptionArgs args)
{
using (TransactionScope transaction = CreateTransactionScope())
{
args.Proceed();
transaction.Complete();
}
}
that results in the following error: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) This only seems to happen for calls to save, and not delete or get calls.
I was wondering if anyone had encountered anything similar ever?
Yes, I've encountered this. Usually its a 64/32 bit problem. Check the target in your project settings.
Jfar is right; That exception means that you either have 64-bit code calling 32-bit code, or vice versa.
I've encountered it before as well.
Here are the steps I used to fix it:
- Check whether the host OS this is run on is 64-bit.
Verify (for our debugging purposes) that the build is not targeting "Any-CPU". Force it to target 64 bit if all of the DLLs you're using are 64 bit (see steps #2 and #3), otherwise target 32-bit otherwise.
Check your PostSharp download and make sure it's a 64-bit DLL.
- Check NHibernate 2.0, and make sure you're using the 64-bit version.
You cannot mix 32-bit DLLs and a 64-bit application (or vice-versa.
If none of that works, try the steps outlined here.
That's odd. What tells PEVERIFY if you execute it on PostSharp output?
精彩评论