cad二次开发 有没有大佬知道这个为什么报错,该怎么解决

图片说明

图片说明

public void show() {
DocumentCollection docs = Application.DocumentManager;
string path1 = @"C:\Users\Wen\Documents\Tencent Files\FileRecv\123.dwg";
docs.Open(path1, false);
foreach (Document item in Application.DocumentManager)
{
if (item.Name.ToLower()==path1.ToLower()) {
Application.DocumentManager.MdiActiveDocument = item;
}
}
Database db_ = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db_.TransactionManager.StartTransaction())
{
foreach (long item in dele)
{
Handle handle = new Handle(item);
ObjectId objId = db_.GetObjectId(false, handle, 0);
Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForWrite);
ent.ColorIndex = 1;
}
}
}

(Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForWrite); 这段代码报错)

“Autodesk.AutoCAD.Runtime.Exception”类型的异常在 AcdbMgd.dll 中发生,但未在用户代码中进行处理

其他信息: eUnknownHandle

应该是你传入了一个空的handle