<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565705#M5438</link>
    <description>&lt;P&gt;Yes, with the debug, I can assure that the problem is from there. I try to manage with this error for a some months&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 23:15:26 GMT</pubDate>
    <dc:creator>m.chavet7MJRB</dc:creator>
    <dc:date>2024-02-16T23:15:26Z</dc:date>
    <item>
      <title>Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12564012#M5434</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a post a few months ago at this location:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://forums.autodesk.com/t5/net/bug-when-successively-launching-a-function-i-ve-created/m-p/12340032" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/net/bug-when-successively-launching-a-function-i-ve-created/m-p/12340...&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;, which I validated too quickly by mistake... As it happens, the problem still persists.&lt;/P&gt;&lt;P&gt;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 :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Application does not support just-in-time (JIT)&lt;BR /&gt;debugging. See the end of this message for details.&lt;/P&gt;&lt;P&gt;************** Exception Text **************&lt;BR /&gt;Autodesk.Gis.Map.MapImportExportException: Exception of type 'Autodesk.Gis.Map.MapImportExportException' was thrown.&lt;BR /&gt;at Autodesk.Gis.Map.ImportExport.Importer.Init(String formatName, String fileName)&lt;BR /&gt;at AEPCreateProfile.MyCommandsAEP.AEPImportShape() in C:\Users\maxime.chavet\Documents\RDC29\VISUAL_STUDIO\Profile\Profile\Class1.cs:line 68&lt;BR /&gt;at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)&lt;BR /&gt;at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)&lt;BR /&gt;at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)&lt;BR /&gt;at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the first code to import shapefile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is at :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;il.SetDataMapping(ImportDataMapping.NewObjectDataOnly, fname);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And for the second :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error is at the last line : foreach (Record record....)&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 08:44:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12564012#M5434</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2024-02-16T08:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12564227#M5435</link>
      <description>&lt;P&gt;The exception is in this line:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;importer.Init("SHP", shpname);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Feb 2024 10:59:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12564227#M5435</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-02-16T10:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565174#M5436</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Indeed sorry, but if I delete the line about the objectdata, it works. So the problem comes from there.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 18:19:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565174#M5436</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2024-02-16T18:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565698#M5437</link>
      <description>&lt;P&gt;Your code contains an empty catch block. What that does is suppress&lt;/P&gt;&lt;P&gt;and hide exceptions. It is something that you should never do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to know where your code first fails, add some code to the catch block that will display the exception on the command line.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:07:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565698#M5437</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-02-16T23:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when I try to touch ObjectData twice in a row in the same C3D session with C#.Net</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565705#M5438</link>
      <description>&lt;P&gt;Yes, with the debug, I can assure that the problem is from there. I try to manage with this error for a some months&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:15:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-when-i-try-to-touch-objectdata-twice-in-a-row-in-the/m-p/12565705#M5438</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2024-02-16T23:15:26Z</dc:date>
    </item>
  </channel>
</rss>

