PostSharp 2.0 BadImageFormatException

发布于 2024-08-18 13:35:11 字数 480 浏览 2 评论 0原文

我们这里有一个应用程序,它使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无远思近则忧 2024-08-25 13:35:11

是的,我遇到过这种情况。通常是 64/32 位问题。检查项目设置中的目标。

Yes, I've encountered this. Usually its a 64/32 bit problem. Check the target in your project settings.

2024-08-25 13:35:11

Jfar 是对的;该异常意味着您要么有 64 位代码调用 32 位代码,要么反之亦然。

我以前也遇到过。

以下是我用来修复该问题的步骤:

  1. 检查运行此程序的主机操作系统是否为 64 位。
  2. 验证(出于调试目的)构建针对“Any-CPU”。如果您使用的所有 DLL 都是 64 位,则强制其以 64 位为目标(请参阅步骤 #2 和 #3),否则以 32 位为目标。

  3. 检查您下载的 PostSharp 并确保它是 64 位 DLL。

  4. 检查 NHibernate 2.0,并确保您使用的是 64 位版本。

不能混合使用 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:

  1. Check whether the host OS this is run on is 64-bit.
  2. 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.

  3. Check your PostSharp download and make sure it's a 64-bit DLL.

  4. 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.

北斗星光 2024-08-25 13:35:11

这很奇怪。
如果在 PostSharp 输出上执行 PEVERIFY,什么会告诉它?

That's odd.
What tells PEVERIFY if you execute it on PostSharp output?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文