<?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: Assembly Load problem in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920717#M49662</link>
    <description>&lt;P&gt;Actually I was editing my previous post while you sent your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem with the command you mentioned i.e.&lt;/P&gt;&lt;PRE&gt;Application.SetSystemVariable("FILEDIA", 0)&lt;/PRE&gt;&lt;P&gt;is that I have to add following Refs to my project tobe able to benefit this code.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;acmgd.dll&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;acdbmgd&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;dll&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;accoremg&lt;/SPAN&gt;&lt;EM&gt;d.dll&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Which is basically impossible to import them in an EXE application (as we all know).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2013 21:48:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-05-13T21:48:10Z</dc:date>
    <item>
      <title>Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3919354#M49657</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing an EXE .net application and I need to, somehow, use &lt;STRONG&gt;NETLOAD&lt;/STRONG&gt; and load a dll file. As far as I understood from &lt;A target="_blank" title="Loading .NET modules programmatically into AutoCAD" href="http://through-the-interface.typepad.com/through_the_interface/2008/09/loading-net-mod.html"&gt;here&lt;/A&gt;, following line would be the key for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Assembly.LoadFrom( &amp;lt;...full path to my DLL file...&amp;gt; )&lt;/PRE&gt;&lt;P&gt;I run the code and&amp;nbsp;&lt;SPAN&gt;I get no error - AutoCAD has been set to be &lt;EM&gt;Visible&lt;/EM&gt; since I am still debuging my code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Meanwhile the subroutine's meta&amp;nbsp;data is not recognised at all&amp;nbsp;- as if the DLL file has not been loaded in AutoCAD.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any idea what that might be for?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 04:54:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3919354#M49657</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T04:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3919916#M49658</link>
      <description>Hi,&lt;BR /&gt;Did you try to load your DLL manually via NETLOAD command? If not I would recommend you to do so. If manually DLL loading is working then you can try for automatic loading. and to understand what have you done put your code also? otherwise people cannot help you.</description>
      <pubDate>Mon, 13 May 2013 10:51:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3919916#M49658</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T10:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920063#M49659</link>
      <description>&lt;P&gt;Yes, code Assembly.LoadFrom/LoadFile() is the same as NETLOAD command in AutoCAD, if the code code is called inside AutoCAD process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, since you are doing EXE, which is a separate process from AutoCAD, even you are automating AutoCAD (via COM API), if you call Assemly.Loadxxx() in your EXE project, the DLL is loaded into your EXE process, not into AutoCAD process. Since the code in the DLL is for AutoCAD and likely has references to acdbmgd/acmgd/accore.dll, which cannot be used outside AutoCAD process, that is why you get error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you automate AutoCAD froom EXE via COM, you'd better to make sure the .NET DLL is somehow automatically loaded into AutoCAD on its startup. Or, you want to make things more complicated (and often unnecessarily)&amp;nbsp;by expose your functionality in the .NET DLL to COM, so that you can access it from outside AutoCAD via COM API.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 13:32:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920063#M49659</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-13T13:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920696#M49660</link>
      <description>&lt;P&gt;Thanks for the clear response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I have another question:&lt;STRONG&gt; Is there any possibility to set a AutoCAD variable via COM API?&lt;/STRONG&gt; If the answer is &lt;STRONG&gt;&lt;EM&gt;Yes&lt;/EM&gt;&lt;/STRONG&gt;, then I can set &lt;STRONG&gt;&lt;EM&gt;FILEDIA&lt;/EM&gt; &lt;/STRONG&gt;value to&lt;STRONG&gt; 0&lt;/STRONG&gt; and then I could pass my dll path to AutoCAD using following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;app.ActiveDocument.SendCommand("NETLOAD" &amp;amp; vbCr)
app.ActiveDocument.SendCommand("...&amp;lt;DLL path&amp;gt;..." &amp;amp; vbCr)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can't I?&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 21:22:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920696#M49660</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T21:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920710#M49661</link>
      <description>&lt;P&gt;Yes, you can set AutoCAD's system variable via AcadDocument:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acadApp.AcitveDocument.SetVariable "FILEDIA", 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, if you use SemdCommand to execute "NETLOAD", and you obviously want to execute some commands defined in your .NET DLL after the DLL is loaded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, your EXE app's execution of SendCommand may not wait the NETLOAD being completed (especially, if your DLL implementing IExtensionApplication, which do qite somework) and just jump to next line of code (after SemdCommand("NETLOAD"....). That is, you'd better only call SendCommand() from your external app only once as LAST action it ask AutoCAD to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if you have to automate AutoCAD this way, you'd better, (as I suggested previously) consider some autoloading .NET DLL approach, or loading them on demaond...&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 21:38:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920710#M49661</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-13T21:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920717#M49662</link>
      <description>&lt;P&gt;Actually I was editing my previous post while you sent your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem with the command you mentioned i.e.&lt;/P&gt;&lt;PRE&gt;Application.SetSystemVariable("FILEDIA", 0)&lt;/PRE&gt;&lt;P&gt;is that I have to add following Refs to my project tobe able to benefit this code.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;acmgd.dll&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;acdbmgd&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;dll&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;accoremg&lt;/SPAN&gt;&lt;EM&gt;d.dll&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Which is basically impossible to import them in an EXE application (as we all know).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 21:48:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920717#M49662</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T21:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920719#M49663</link>
      <description>&lt;P&gt;I appologise. I did not read your response thoroughly enough.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I though you meant&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Application.SetSystemVariable&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;My bad&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://forums.autodesk.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 21:51:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920719#M49663</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T21:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920762#M49664</link>
      <description>&lt;P&gt;Although even with &lt;EM&gt;acadApp.AcitveDocument.SetVariable&lt;/EM&gt;&amp;nbsp;, the following exception is thrown:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public memeber 'ActiveDocument' on type 'IAcadApplication' not found&amp;nbsp;&lt;img id="smileymad" class="emoticon emoticon-smileymad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-mad.png" alt="Smiley Mad" title="Smiley Mad" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 22:39:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3920762#M49664</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-13T22:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3921918#M49665</link>
      <description>&lt;P&gt;Depending on how AutoCAD is started, there may or may not be an ActiveDocument. It looks like you launch AutoCAD from your EXE app. Iin this case, unless you expliciltly open&amp;nbsp;a new or existing drawing, the AutoCAd session will not have an ActiveDocument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, before you can use AcadDocument.SetVariable() method, or any methods of the AcadDocument class for that matter, you need to obtain an instance of AcadDocument, be it ActiveDocument or not. Without seeing more of your code as what it exactly does, it is difficult to say more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 13:30:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3921918#M49665</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-14T13:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3922594#M49666</link>
      <description>&lt;P&gt;Thank you again Norman but I am afraid that's not the case. I put my code here to have a look:&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;&lt;PRE&gt;Public Function InAutoCAD(FilePath As String) As Boolean
        Dim GivenTaskStatus As Boolean = False
        Const progID As String = "AutoCAD.Application.19"
        'Const DllPath As String = "C:\DLL file.dll"
        Dim acApp As AcadApplication = Nothing
        Try
            acApp = DirectCast(Marshal.GetActiveObject(progID), AcadApplication)
        Catch
            Try
                Dim acType As Type = Type.GetTypeFromProgID(progID)
                acApp = DirectCast(Activator.CreateInstance(acType, True), AcadApplication)
            Catch
                GivenTaskStatus = False
                MessageBox.Show("Cannot create object of type """ + progID + """")
            End Try
        End Try
        If acApp IsNot Nothing Then
            Try
                acApp.Visible = True
                acApp.WindowState = AcWindowState.acMax
                Dim doc As AcadDocument = acApp.Documents.Open(FilePath)
                doc.Activate()

                ''╔════════ Loading DLL file ═══════╗
                'acApp.AcitveDocument.SetVariable("FILEDIA", 0)
                'Try
                '    acApp.ActiveDocument.SendCommand("NETLOAD" &amp;amp; vbCr &amp;amp; DllPath &amp;amp; vbCr)
                'Catch ex As System.Exception
                '    MsgBox(vbLf &amp;amp; "Cannot load {0}: {1}", DllPath, ex.Message)
                'End Try
                ''╚════════ Loading DLL file ═══════╝

                'acApp.ActiveDocument.SendCommand("MYCOMMAND" + vbCr)

                'saving document
                doc.Close(True)

                GivenTaskStatus = True
            Catch ex As Exception
                GivenTaskStatus = False
                MessageBox.Show(Me, "Problem executing component: " + ex.Message)
            End Try
        End If
        Return GivenTaskStatus
    End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having said that, I am not happy with AutoCAD launching part of the code as well. It looks bogus to me. It gives me following error at my very first run of the code (cold start).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="6a00d83452464869e20120a8d6eb55970b.png" border="0" src="https://forums.autodesk.com/t5/image/serverpage/image-id/52516iFD983DB97D536FB5/image-size/original?v=mpbl-1&amp;amp;px=-1" title="6a00d83452464869e20120a8d6eb55970b.png" align="center" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But after re-running the code couple of times, that error will not pup up again and AutoCAD is simply launched. Any idea what that might be for?&lt;/P&gt;&lt;P&gt;I found &lt;A target="_self" href="http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-by-autocad-from-an-external-net-application.html"&gt;this &lt;/A&gt;by Google but unfortunately that article is too technical for me to comprehend &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 21:09:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3922594#M49666</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-14T21:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly Load problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3922650#M49667</link>
      <description>You can have a look on below links. It might be helpful for you.&lt;BR /&gt;&lt;BR /&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2010/02/creating-demand-loading-entries-for-net-modules-outside-of-autocad.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2010/02/creating-demand-loading-entries-for-net-modules-outside-of-autocad.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2009/05/creating-demand-loading-entries-automatically-for-your-autocad-application-using-net.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2009/05/creating-demand-loading-entries-automatically-for-your-autocad-application-using-net.html&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 May 2013 22:31:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/assembly-load-problem/m-p/3922650#M49667</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-14T22:31:12Z</dc:date>
    </item>
  </channel>
</rss>

