【问题标题】:Issue related to Openfiledialog control in C#与 C# 中的 Openfiledialog 控件相关的问题
【发布时间】:2012-07-21 17:30:09
【问题描述】:

我在 Win C# 2010 中有一个应用程序,

我在表单中添加了 OpenFileDialog 控件。我编写了以下代码

OpenFileDialog1.ShowDialog();

它抛出以下异常:

AccessViolationException:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

可能是什么问题?以及如何解决?

谢谢..

【问题讨论】:

  • 您可能需要创建 OpenFileDialog 控件的实例,我不确定您是否可以这样做...
  • 能否提供完整代码?以及您要实施什么?
  • 我的电脑最近遇到了类似的问题。关闭 Windows 的 Aero 主题,然后重试。
  • 使用 SysInternals 的 AutoRuns 实用程序并禁用 shell 扩展。

标签: c# .net winforms


【解决方案1】:

【讨论】:

    【解决方案2】:

    这是正确的方法:

    OpenFileDialog of = new OpenFileDialog();
    of.ShowDialog();
    

    编辑 此外,在运行某些类型的驱动程序软件或防病毒程序的计算机上的 .NET Framework 2.0 Remoting 应用程序中可能会出现此问题。

    Source

    如需测试,请关闭杀毒软件。

    【讨论】:

    • 这取决于 OP 如何添加 OpenFileDialog 组件。如果 OP 直接在代码中添加 OpenFileDialog 那么这可能是答案,但如果 OP 使用设计器拖动 OpenFileDialog 组件,那么还有另一个导致崩溃的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 2011-01-13
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多