我已经绕过了这个错误。你说得对,基思。MdiActiveDocument在我的电脑上工作得非常好,但在其他任何人的电脑上都不工作(原因不明)。我已经包括了这个系统。EnterpriseServices作为参考,因此这没有帮助,但现在它取代了Application.DocumentManager。MdiActiveDocument,我在类中使用以下属性来为我获取活动文档。
- public Document ActiveDocument
- {
- get
- {
- // This is the CORRECT way to get the active document. Application.MdiActiveDocument is fried!!!
- Database db = HostApplicationServices.WorkingDatabase;
- try
- {
- Document d = Application.DocumentManager.GetDocument(db);
- return d;
- }
- catch
- {
- System.Windows.Forms.MessageBox.Show("Cannot connect to AutoCAD document.");
- return null;
- }
- }
- }
|