Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I created a post a few months ago at this location: https://forums.autodesk.com/t5/net/bug-when-successively-launching-a-function-i-ve-created/m-p/12340... , which I validated too quickly by mistake... As it happens, the problem still persists.
In the same project session, when I try again to touch ObjectData (by importing them, or if I want to reread the "records" a second time), I always get the error :
Application does not support just-in-time (JIT)
debugging. See the end of this message for details.
************** Exception Text **************
Autodesk.Gis.Map.MapImportExportException: Exception of type 'Autodesk.Gis.Map.MapImportExportException' was thrown.
at Autodesk.Gis.Map.ImportExport.Importer.Init(String formatName, String fileName)
at AEPCreateProfile.MyCommandsAEP.AEPImportShape() in C:\Users\maxime.chavet\Documents\RDC29\VISUAL_STUDIO\Profile\Profile\Class1.cs:line 68
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
Here is the first code to import shapefile:
[CommandMethod("SHP2")] static public void SHP2() { Autodesk.AutoCAD.Windows.OpenFileDialog ofd = new Autodesk.AutoCAD.Windows.OpenFileDialog( "Select SHP File", null, "shp", "Select shp", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowAnyExtension); if (ofd.ShowDialog() == DialogResult.OK) { string shpname = ofd.Filename; Import2(shpname); }// }//acad command - SHP2 private static void Import2(string shpname) { string fname = Path.GetFileNameWithoutExtension(shpname).Replace(" ", ""); MapApplication mapApp = HostMapApplicationServices.Application; Importer importer = mapApp.Importer; try { importer.Init("SHP", shpname); foreach (InputLayer il in importer) { il.SetLayerName(LayerNameType.LayerNameDirect, fname); il.SetDataMapping(ImportDataMapping.NewObjectDataOnly, fname); }// foreach shp layer importer.ImportPolygonsAsClosedPolylines = true; ImportResults ir = importer.Import(true); } catch { } finally { }; }// Import2
Problem is at :
il.SetDataMapping(ImportDataMapping.NewObjectDataOnly, fname);
And for the second :
using(DocumentLock lk = doc.LockDocument()) { if (psr.Status == PromptStatus.OK) { foreach (SelectedObject so in psr.Value) { using (Records records = tables.GetObjectRecords(0, so.ObjectId, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, false)) { foreach (Record record in records) //Error at this line
Error is at the last line : foreach (Record record....)