【发布时间】:2012-01-10 18:24:50
【问题描述】:
我编写了一个外部应用程序来驱动 autocad,它带有一个为 COM 注册的 dll。我已经按照this codes 编写了我的应用程序,但是我用 AddNumbers() 方法替换了以下代码:
public string OpenDWGFile(string MyDWGFilePath)
{
DocumentCollection dm = Application.DocumentManager;
Document doc = null;
if(File.Exists(MyDWGFilePath))
{
doc = dm.Open(MyDWGFilePath, false);
Application.DocumentManager.MdiActiveDocument = doc;
return "This file is exists";
}
else
return "This file is not exist";
}
但是当我运行我的应用程序时,autocad 软件会立即打开然后关闭,并显示此错误消息:调用目标已引发异常。
但如果我在我的代码中注释以下行,则应用程序可以正常工作:
doc = dm.Open(MyDWGFilePath, false);
Application.DocumentManager.MdiActiveDocument = doc;
【问题讨论】: