创建Database时可以传入两个参数new Database(buildDefaultDrawing,noDocument)
其中第二个参数表示是否与当前文档产生关联(帮助的原文 specifying whether or not to associate this database to the current document)
如果没有关联,还好理解,就是无任何关系。那么有关联时,新建的Database对象与当前文档之间有什么关系呢?能体现在什么地方?
The second parameter of the Database constructor (noDocument) controls if the Database should be associated with the current document or not.
Probably the main reason to decide to associate the Database with a document would be to participate in Undo: see ObjectARX Reference > Document-Independent Databases
In this case you would need to do document locking (and since you are in Session context because of CommandFlags.Session, you would need to do it yourself, explicitly, using Document.LockDocument())
However if you do not associate the Database with the current document, then no locking is needed.
So the solution is to either lock the Document when you want to associate your Database with it (noDocument = false):