diff --git a/src/CAD/IFox.CAD.Shared/Runtime/DBTrans.cs b/src/CAD/IFox.CAD.Shared/Runtime/DBTrans.cs index b7617b5585bc3cd44f826c924ea6f5bcf5d2ea78..3b096decab4fd759909d4a5671c4f2318329b7f3 100644 --- a/src/CAD/IFox.CAD.Shared/Runtime/DBTrans.cs +++ b/src/CAD/IFox.CAD.Shared/Runtime/DBTrans.cs @@ -241,15 +241,26 @@ public DBTrans(string fileName, if (doc is null) { Database = new Database(false, true); - if (Path.GetExtension(_fileName).ToLower().Contains("dxf")) + try + { + if (Path.GetExtension(_fileName).ToLower().Contains("dxf")) + { + Database.DxfIn(_fileName, null); + } + else + { + Database.ReadDwgFile(_fileName, fileOpenMode, true, password); + } + } + catch { - Database.DxfIn(_fileName, null); + IsDisposed = true; // 读取出错造成未能 push, 固这里设为 true + throw new ArgumentException($"文件 [{fileName}] 的格式版本可能高于当前CAD版本,读取错误!"); } - else + finally { - Database.ReadDwgFile(_fileName, fileOpenMode, true, password); + Database.CloseInput(true); } - Database.CloseInput(true); } else {