【问题标题】:Visio drawing control AccessViolationException on adding a shape添加形状时的 Visio 绘图控件 AccessViolationException
【发布时间】:2013-05-11 01:31:56
【问题描述】:

我有一个带有Visio Drawing Control 的表单。我正在使用Visio Drawing Control 11.0(我的 PC 上安装了 Visio 2003)。在表单加载事件中,我执行以下操作:

private void Form1_Load(object sender, EventArgs e)
{
    this.axDrawingControl1.Src = @"D:\visio test\drawing.vsd";
    Document currentStencil = this.axDrawingControl1.Document.Application.Documents.OpenEx(@"Basic_U.vss", (short)VisOpenSaveArgs.visOpenDocked);
    Window stencilWindow = this.axDrawingControl1.Document.OpenStencilWindow();
}

当我运行应用程序时,我向文档添加了一个形状,然后应用程序崩溃并显示 AccessViolationException. 错误消息显示 Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
但是,当我通过将DrawingControl.Src 属性设置为文档的文件名来打开文档时,应用程序工作正常,但我需要打开文档并使用编辑它绘图控件。

有没有办法解决这个问题?

【问题讨论】:

    标签: c# com access-violation visio


    【解决方案1】:

    您可能需要等到文档完全加载。

    为 this.axDrawingControl1.DocumentOpened 添加一个事件处理程序,并将您的绘图代码移动到该处理程序。

    【讨论】:

    • 重启电脑解决了问题,呵呵。还是谢谢你。
    猜你喜欢
    • 2017-03-13
    • 2022-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    相关资源
    最近更新 更多