PostSharp 2.0 BadImageFormatException
我们这里有一个应用程序,它使用 postsharp 将某些方法包装在从 MethodInterceptionAspect 派生的事务方面中。我们使用 NHibernate 2.0 作为应用程序的 ORM。此代码块中存在故障,
public override void OnInvoke(MethodInterceptionArgs args)
{
using (TransactionScope transaction = CreateTransactionScope())
{
args.Proceed();
transaction.Complete();
}
}
导致以下错误: System.BadImageFormatException:尝试加载格式不正确的程序。 (HRESULT 异常:0x8007000B) 这似乎只发生在保存呼叫时,而不是删除或接听呼叫时。
我想知道有人遇到过类似的事情吗?
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. There 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,我遇到过这种情况。通常是 64/32 位问题。检查项目设置中的目标。
Yes, I've encountered this. Usually its a 64/32 bit problem. Check the target in your project settings.
Jfar 是对的;该异常意味着您要么有 64 位代码调用 32 位代码,要么反之亦然。
我以前也遇到过。
以下是我用来修复该问题的步骤:
验证(出于调试目的)构建不针对“Any-CPU”。如果您使用的所有 DLL 都是 64 位,则强制其以 64 位为目标(请参阅步骤 #2 和 #3),否则以 32 位为目标。
检查您下载的 PostSharp 并确保它是 64 位 DLL。
您不能混合使用 32 位 DLL 和 64 位应用程序(反之亦然。
如果这些都不起作用,请尝试以下步骤此处概述。
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:
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.
You cannot mix 32-bit DLLs and a 64-bit application (or vice-versa.
If none of that works, try the steps outlined here.
这很奇怪。
如果在 PostSharp 输出上执行 PEVERIFY,什么会告诉它?
That's odd.
What tells PEVERIFY if you execute it on PostSharp output?