.NET/VB6 应用程序在 Windows 7 上失败

发布于 2024-10-03 06:03:40 字数 1088 浏览 0 评论 0原文

我有一个 .NET 3.5 winforms 应用程序,它调用 VB6 ActiveX DLL 中的方法,这会弹出一个对话框。近 10 年来一切都运行良好(首先是 .NET 1.1 应用程序,然后是 2.0,然后是 3.5,全部运行在 Windows XP 上)。现在客户已升级到 Windows 7,我遇到了 System.AccessViolationException:尝试读取或写入受保护的内存。这通常表明其他内存已损坏。

调用的结构如下所示:

.NET 代码

try {
  VB6Object obj = new VB6Object();
  obj.DoStuff();
}
catch (Exception ex) {  // handle }

VB6Object 类中的 VB6 代码

Public Sub DoStuff()
    on error goto errHandle
    RetrieveData();

    Call frmPopup.Show(vbModal)

exitPoint:
    exit sub
errHandle: 
    ' handle error
End Sub

问题始于此行的 VB6 代码:Call frmPopup.Show(vbModal)。该错误被传播到我处理错误的 .NET 代码(VB6 代码中的错误处理程序被完全忽略)。我认为问题可能是 frmPopup 的 Load 事件,但代码永远不会到达 Load 事件(我到处都有跟踪语句,所以这就是我知道的)。

有趣的是,我第二次拨打电话时,它根本没有失败,但表单缺少第 3 方网格(ActiveX DevExpress Quantum Grid),因此我假设该网格可能与 Windows 不兼容7.

当我只是将应用程序作为 EXE 或从 VS2008 IDE 运行时,我所描述的一切都会发生,因此 VB6 ActiveX DLL 只是一个参考。如果我使用 COM 间接并在 IDE 中运行 VB6 代码,一切都会正常工作。

我尝试以管理员身份运行,但没有任何改变。

接下来我可以去哪里解决这个问题?

I have a .NET 3.5 winforms app that calls a method in a VB6 ActiveX DLL, which brings up a dialog box. Everything worked fine for almost 10 years (first as a .NET 1.1 app, then 2.0, then 3.5, all on Windows XP). Now that the customer has upgraded to Windows 7, I am experiencing a System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The structure of the call is like this:

.NET Code

try {
  VB6Object obj = new VB6Object();
  obj.DoStuff();
}
catch (Exception ex) {  // handle }

VB6 code in VB6Object class

Public Sub DoStuff()
    on error goto errHandle
    RetrieveData();

    Call frmPopup.Show(vbModal)

exitPoint:
    exit sub
errHandle: 
    ' handle error
End Sub

The problem starts in the VB6 code on this line: Call frmPopup.Show(vbModal). The error is propagated to the .NET code (error handlers in the VB6 code are completely ignored) where I handle the error. I thought the problem might be the Load event of the frmPopup, but the code does not ever reach the Load event (i have tracing statements all over the place, so that's how I know).

The interesting part is that the second time I make the call, it does not fail at all, but the form is missing a 3rd party grid (ActiveX DevExpress Quantum Grid), so I am assuming that the grid is probably not compatible somehow with Windows 7.

Everything that I have described happens when I simply run the application as an EXE or from VS2008 IDE, so the VB6 ActiveX DLL is simply a reference. If I use COM indirection and run the VB6 code in the IDE, everything works perfectly fine.

I've tried running things as an Administrator, but nothing changed.

Where can I go next to troubleshoot this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

嗼ふ静 2024-10-10 06:03:40

关闭 DEP。较旧的 Axe 控件倾向于使用时髦的子类化 thunk(ATL/MFC 除外),没有人关心将 NX 标志设置为关闭。

Turn DEP off. Older Ax Controls tend to use funky subclassing thunks (other than ATL/MFC ones) that no one cares to set the NX flag off.

淡笑忘祈一世凡恋 2024-10-10 06:03:40

确保针对 x86 目标而不是任何 CPU 进行编译,尤其是在 64 位系统上运行时。当您在 64 位 Windows 7 系统上使用带有旧版 32 位 DLL 的任何 CPU 时,会出现某种冲突,并且引用旧的 IBM 手册,“结果是不可预测的”。

Make sure you are compiling for the x86 target instead of anyCPU, especially if you run on 64-bit systems. There is some kind of conflict when you use anyCPU with an older 32-bit DLL on a 64-bit Windows 7 system, and, to quote the old IBM manuals, "the results are unpredictable."

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