<?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: How to connect AutoCAD (user specified version) using VB.Net via COM Library? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12585981#M5309</link>
    <description>&lt;P&gt;Since you set reference to AutoCAD's COM type library, and you declared the variable "Cadapp" as AcadApplication (you DID not show the code where the Cadapp variable is declared, but I assume you did so because of the question you post here), that means you use EARLY BINDING, that is, the the types (AcadXxxxx) of AutoCAD object models are bound to certain version of AutoCAD COM Classes when the code is compiled. Therefore, the code you showed here in attempt to start different version of AutoCAD is meaningless, as you have already experienced.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want your COM API code works with multiple versions of AutoCAD, you need to use LATE BINDING, so that the code is not compiled against specific version of AutoCAD COM API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2024 16:24:38 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2024-02-27T16:24:38Z</dc:date>
    <item>
      <title>How to connect AutoCAD (user specified version) using VB.Net via COM Library?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12584690#M5308</link>
      <description>&lt;P&gt;Dear Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my Vb.Net Project,&amp;nbsp; connecting AutoCAD 2020 using the COM type Library by selecting the Reference&amp;nbsp; (AutoCAD Version 2020)&amp;nbsp;manually &amp;amp; Internally code modified the version 2020. Its working fine.&lt;/P&gt;&lt;P&gt;(Cannot change to Net Library, built lot of Standard functions based on this COM)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose if user want to connect AutoCAD 2024, once again i have to modify the COM Reference (AutoCAD Version - 2024)&amp;nbsp; then will modify the connection portion inside the code based on version.&lt;/P&gt;&lt;P&gt;For Each user we can't built Project, not good Automation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Query : Based on User Input (Version2024), connect AutoCAD 2024 via COM Library, along with reference base version 2020?&amp;nbsp; (Is it possible Deselect 2020 reference and Select 2024 Reference inside code?)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code, not working - results in Error.&lt;/P&gt;&lt;P&gt;Please give Suggestions to achieve this,&amp;nbsp;&lt;SPAN&gt;Thanks by advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Code Snippet:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Need to open AutoCAD 2024:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;' -Manually&amp;nbsp; added AutoCAD 2020 reference (below picture) - for built up the project&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Public Shared Sub connect_cad()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'CAD_Version&amp;nbsp; -- user input&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 'Dim CAD_Version As String = "AutoCAD.Application.23.1"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Autocad 2020 user input&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(working fine)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim CAD_version As String = "AutoCAD.Application.24.3"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' AutoCAD 2024 user input&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(getting error)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Try&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject(CAD_version), AcadApplication) ''&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GetObject(, "AutoCAD.Application")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If&amp;nbsp; Cadapp.Documents.Count = 0 Then Cadapp.Documents.Add()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.Visible = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Catch Ex As Exception&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CADOPEN = False&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Err.Clear()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp = CType(CreateObject(CAD_version), AcadApplication)&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;'Error coming here&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Err.Number &amp;lt;&amp;gt; 0 Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CADOPEN = False&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MsgBox(Err.Description)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exit Sub&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp.Visible = True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;Else&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Cadapp.Documents.Count = 0 Then Cadapp.Documents.Add()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;conect_cad_option = True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp.Visible = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; End If&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Finally&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;End Try&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;FONT color="#FF0000"&gt;Error Msg:&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" color="#FF0000"&gt;System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'AutoCAD.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6323190E-C6ED-434C-A368-E9314A8D7597}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This Picture - Manually added Reference for AutoCAD Version 2020&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="muthukumarkVVK9E_0-1709011243810.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1330670i4E0E04F41605B257/image-size/large?v=v2&amp;amp;px=999" role="button" title="muthukumarkVVK9E_0-1709011243810.png" alt="muthukumarkVVK9E_0-1709011243810.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 05:21:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12584690#M5308</guid>
      <dc:creator>muthukumar.kVVK9E</dc:creator>
      <dc:date>2024-02-27T05:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to connect AutoCAD (user specified version) using VB.Net via COM Library?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12585981#M5309</link>
      <description>&lt;P&gt;Since you set reference to AutoCAD's COM type library, and you declared the variable "Cadapp" as AcadApplication (you DID not show the code where the Cadapp variable is declared, but I assume you did so because of the question you post here), that means you use EARLY BINDING, that is, the the types (AcadXxxxx) of AutoCAD object models are bound to certain version of AutoCAD COM Classes when the code is compiled. Therefore, the code you showed here in attempt to start different version of AutoCAD is meaningless, as you have already experienced.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want your COM API code works with multiple versions of AutoCAD, you need to use LATE BINDING, so that the code is not compiled against specific version of AutoCAD COM API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 16:24:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12585981#M5309</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-02-27T16:24:38Z</dc:date>
    </item>
  </channel>
</rss>

