.NET Windows 7 特定错误

标签 .net visual-studio visual-studio-2010 windows-7 .net-2.0

我有一个 .NET 应用程序及其设置。使用 VS 2005 构建。

开发机器是Windows XP SP3。

曾经有人在Windows7下安装过它。并出现以下错误

WinForm 线程异常

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Windows.Forms.UnsafeNativeMethods.IOleObject.DoVerb(Int32 iVerb, IntPtr lpmsg, IOleClientSite pActiveSite, Int32 lindex, IntPtr hwndParent, COMRECT lprcPosRect) at System.Windows.Forms.AxHost.DoVerb(Int32 verb) at System.Windows.Forms.AxHost.InPlaceActivate()

其他

Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown. Method 'Disconnect' cannot be invoked at this time.

现在,想知道问题出在哪里,并在Windows7上安装了VS 2005。 现在,该解决方案可以编译并运行,没有任何异常。我构建了安装程序,并在这台 Win7 机器上重新安装了新构建的安装程序...

我得到了异常(exception)。为什么会这样?

应用程序在使用 VS 启动时没有异常,但在启动已安装的可执行文件后抛出异常...

但是,我成功(无一异常(exception))在某些操作系统 > Win XP 的计算机上测试了已安装的应用程序:Windows 7 (x64) 和 Windows Server 2008 (x64) ...

通过研究日志,我发现了产生异常的代码:

Panel p = new Panel();
p.Margin = new Padding(0);
p.Dock = DockStyle.Fill;
p.Controls.Add(display); // 'display' is an ActiveX control instance

Logger.LogMessage("before");

this.tableLayoutPanel.Controls.Add(p); // protected memory EXCEPTION

Logger.LogMessage("after");

所以,我看到“之前”,然后AccessViolationException:尝试读取或写入 protected 内存...没有看到“之后 “...

造成此类异常的常见原因是什么?

详细信息

  • 我在应用程序中使用了一些第三方 ActiveX;
  • 使用 ActiveX 的示例(用 C++ 编写)在 native 上运行良好。
  • 该解决方案面向 x86 平台;
  • 我成功地在 **Windows Server 2008 (x64) 和 Windows 7 (x64) 上启动了该应用程序,没有出现任何错误;
  • 尝试使用“Windows XP 兼容性(SP2、SP3)”模式 - 相同的结果(异常(exception))。
  • 尝试将应用程序安装在 ProgramFiles 之外的其他文件夹中。我使用 C:\TestFolder 作为安装路径 - 结果是相同的:AccesViolationException....

最佳答案

哇,x84 CPU,从来没有见过其中一个;-)) 你的意思可能是 x64...

您安装的 Windows XP 是 64 位版本?
这可能是 32/64 位转换问题,而不是 Windows 7 问题。

Forms.UnsafeNativeMethods.IOleObject

你是否调用了你的ActiveX dll?

它是 32 位 dll 还是 64 位 dll? 32 位 dll 无法在 64 位环境中运行,反之亦然。

如果您通过 COM 调用它,您可能还有机会。 但至少在 Linux 上,C/C++ 数据类型 long 在 64 位模式下有 8 个字节,而在 32 位模式下有 4 个字节。

尝试在 .NET 应用程序中以 x86 平台(=32 位)为目标。

关于.NET Windows 7 特定错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3934950/

相关文章:

c# - 我可以将 C# 扩展方法的可见性限制为同一程序集中的类吗?

.net - 数据访问层设计模式

c++ - Visual Studio 2010 中未解析的外部符号

visual-studio-2010 - "Run Custom Tool"用于 MVC2 项目中的 resx 文件(来自外部应用程序/脚本)

.net - SslStream、BEAST 和 TLS 1.1

c# - (400) 错误请求和更新条目时发生错误

visual-studio - Visual Studio 2010中的安装项目: Unknown Publisher?

visual-studio - 如何更改 Visual Studio 2017 中断点的位置

c++ - 错误 LNK2019 : unresolved external symbol

visual-studio-2010 - 如何更改 Visual Studio 2010 工具提示的背景色或前景色