<?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: The .NET example does not work in dialog form. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846280#M22171</link>
    <description>&lt;P&gt;That's right.&lt;BR /&gt;I was looking at the example code with a windows form executable application.&lt;BR /&gt;Thank you for suggesting the right way.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jun 2019 06:13:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-06-12T06:13:56Z</dc:date>
    <item>
      <title>The .NET example does not work in dialog form.</title>
      <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846084#M22167</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am going to run a sample code that generates polylines in the following environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Environment]&lt;/P&gt;&lt;P&gt;VS 2019 communication, ACAD 2018, .NET Framework 4.7.2&lt;/P&gt;&lt;P&gt;[sample code]&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-EC036F5A-1F02-40D3-B348-4193BA58CF0C-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-EC036F5A-1F02-40D3-B348-4193BA58CF0C-htm.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I installed objectARX 2018 to add acax22ENU.tlb and axdb22enu.tlb to the reference in Solution Explorer, and added also AcCorMGD.dll, AcCui.dll, AcDbMgd.dll, and AcMgd.dll.&lt;/P&gt;&lt;P&gt;Then I inserted the create polyline example code in the event of button1_Click, which is causing a problem from here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private void button1_Click(object sender, EventArgs e)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document acDoc = Application.DocumentManager.MdiActiveDocument; &lt;FONT color="#ff0000"&gt;&lt;EM&gt;&lt;STRONG&gt;//&amp;nbsp;issue. Application is an ambiguous reference between Autodesk.AutoCAD.ApplicationServices.Application and System.Windows.Forms.Application.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I avoided the syntax error by explicitly changing it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I run the application and press button1, error occurs that &lt;FONT color="#ff0000"&gt;"Common Language Runtime detected&amp;nbsp;an invalid program."&lt;/FONT&gt; in the modified line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate if you let me know where I made the mistake.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 01:37:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846084#M22167</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-12T01:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: The .NET example does not work in dialog form.</title>
      <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846096#M22168</link>
      <description>&lt;P&gt;Perhaps try something like this :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in your using statements add :&lt;/P&gt;&lt;PRE&gt;using _cadApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/PRE&gt;&lt;P&gt;in your code body use :&lt;/P&gt;&lt;PRE&gt;var doc = _cadApp.DocumentManager.MdiActiveDocument;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 02:07:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846096#M22168</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2019-06-12T02:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: The .NET example does not work in dialog form.</title>
      <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846114#M22169</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;I modified the code as you suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[statements add]&lt;BR /&gt;using _cadApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[code - before]&lt;BR /&gt;Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;[code - after]&lt;BR /&gt;var acDoc = _cadApp.DocumentManager.MdiActiveDocument;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the Common Language Runtime error will still occur when running the application.&lt;BR /&gt;There is still a problem in the acDoc variable creation line.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 02:26:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846114#M22169</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-12T02:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: The .NET example does not work in dialog form.</title>
      <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846231#M22170</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not describe the context the "dialog form" is created.&lt;/P&gt;
&lt;P&gt;I suspect it's a Windows form executable application (exe).&lt;/P&gt;
&lt;P&gt;The AutoCAD API (accoremgd.dll acdbmgd.dll, acmgd.dll libraries) can only be used in AutoCAD application context, i.e. from a dll netloaded in AutoCAD (see &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this topic&lt;/STRONG&gt;&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;You should start from &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-BA686431-C8BF-49F2-946E-9CEB2F7AE4FA" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;here&lt;/STRONG&gt;&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 05:37:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846231#M22170</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-06-12T05:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: The .NET example does not work in dialog form.</title>
      <link>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846280#M22171</link>
      <description>&lt;P&gt;That's right.&lt;BR /&gt;I was looking at the example code with a windows form executable application.&lt;BR /&gt;Thank you for suggesting the right way.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 06:13:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/the-net-example-does-not-work-in-dialog-form/m-p/8846280#M22171</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-12T06:13:56Z</dc:date>
    </item>
  </channel>
</rss>

