<?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 load a dll and run the command by a method in a command? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281753#M36313</link>
    <description>&lt;P&gt;hi gile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; thks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; yes use ed.command maybe ok, but i'd like to try other method instead of cmd.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2016 12:48:44 GMT</pubDate>
    <dc:creator>swaywood</dc:creator>
    <dc:date>2016-04-20T12:48:44Z</dc:date>
    <item>
      <title>how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281349#M36309</link>
      <description>&lt;P&gt;hi all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i have 2 dlls. one is a.dll, the other is b.dll.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and a1 is&amp;nbsp;one of the&amp;nbsp;command in a.dll. b1 is one of the command in b.dll&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; now i netload a.dll and run the a1 command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; in a1 command method how to load b.dll and run b1 command?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; please don't ask me why not netload a.dll and b.dll together…&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 08:35:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281349#M36309</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-20T08:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281668#M36310</link>
      <description>&lt;P&gt;I believe that Autocad will not recognize the command in the b.dll unless you netload it. &amp;nbsp;That being said,&amp;nbsp;every custom command in .NET has a corresponding method that goes with it. &amp;nbsp;In your A.dll just reference the B.dll and then inside of the command in the A.dll just call the method that corresponds to the command in the B.dll. &amp;nbsp;Autocad should load it and then run the method.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 12:04:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281668#M36310</guid>
      <dc:creator>Keith.Brown</dc:creator>
      <dc:date>2016-04-20T12:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281681#M36311</link>
      <description>&lt;P&gt;hi Brown,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; thank you for your reply. in my case ,a.dll is not reference b.dll. i want to use 'System.Reflection' to load dll file.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 12:15:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281681#M36311</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-20T12:15:27Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281730#M36312</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What about using Editor.Command() method for A2015+ or a &lt;A href="https://forums.autodesk.com/t5/net/send-command-executes-after-exiting-command-method/td-p/3882929" target="_blank"&gt;RunCommand() wrapper&lt;/A&gt; (for prior versions) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ed.Command("_netload", "b.dll");
ed.Command("b1");&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 12:37:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281730#M36312</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-04-20T12:37:03Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281753#M36313</link>
      <description>&lt;P&gt;hi gile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; thks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; yes use ed.command maybe ok, but i'd like to try other method instead of cmd.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 12:48:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281753#M36313</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-20T12:48:44Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281880#M36314</link>
      <description>Something like:&lt;BR /&gt;System.Reflection.Assembly.LoadFrom(szYourDllPath);</description>
      <pubDate>Wed, 20 Apr 2016 13:28:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281880#M36314</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-20T13:28:16Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281916#M36315</link>
      <description>&lt;P&gt;i tried this codes, but not success yet. cad version&amp;nbsp;is 2010&lt;/P&gt;&lt;PRE&gt;    public void prjOnlineUpdate()
    {
      object obj = null;
      byte[] filesByte;
      Assembly assembly;
      Type type;
      try
      {
        string folder = Environment.CurrentDirectory;
        if (folder[folder.Length - 1] == '\\')
        {
          folder = folder.Remove(folder.Length - 1);
        }
        //filesByte = File.ReadAllBytes(folder + "//cmdtest.dll");
        //assembly = Assembly.Load(filesByte);
        assembly = Assembly.LoadFrom(folder + "//cmdtest.dll");
        type = assembly.GetType("cmdtest.Class1");
        obj = System.Activator.CreateInstance(type);
        MethodInfo timerStart = type.GetMethod("test");
        if (timerStart != null)
        {
          timerStart.Invoke(obj, null);
        }
      }
      catch (System.Exception)
      {

      }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace cmdTest
{
  public class Class1
  {
    [CommandMethod("test")]
    public void test()
    {
      Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
      ed.WriteMessage("test is ok");
    }
  }
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:34:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281916#M36315</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-20T13:34:38Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281941#M36316</link>
      <description>&lt;P&gt;Did you try just doing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;System.Reflection.Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, b.dll));&lt;BR /&gt;ed.Command("b1");&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:45:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281941#M36316</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-04-20T13:45:59Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281957#M36317</link>
      <description>&lt;P&gt;As you already mentioned, if the a.dll has reference to b.dll, then you do not need to "NETLOAD" b.dll, because when a.dll is netloaded, b.dll is also loaded because of the reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, as you requested, you could load b.dll using System.Reflection whenever needed: Assembly.Load()/LoadFile()/LoadFrom() (there are subltle differences among the 3 loading methods that you need to pay attention). Assembly loaded this way is the same as loaded by Acad's "NETLOAD" command (and the IExtensionApplication will run upon loading). Better yet, before you load the DLL assembly, you not only make sure the dll is in the .NET loading location according to .NET loading poll-mechnism; but also check if the assembly has already been loaded, to which you can use AppDomain.CurrentDomain.GetAssemblies() to find out loaded .NET assemblies (by its fully qualified name/version...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fortunately, the Autodesk.AutoCAD.Runtime.ExtensionLoader class (available since Acad2013?) has Load()/IsLoaded to do exactly the things aforementioned in more simplfied way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:52:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6281957#M36317</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2016-04-20T13:52:08Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283296#M36318</link>
      <description>&lt;P&gt;hi yuan:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; thank you for your reply. i tried 3 load methods, but allways did not get the type(type = null), then 'obj = System.Activator.CreateInstance(type);' got error. could you help me write a test solution based on the code i post? the 2 dll does not reference each other. thank you so much.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 00:49:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283296#M36318</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-21T00:49:59Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283300#M36319</link>
      <description>&lt;P&gt;hi gile:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; thanks for your kindly help, but&amp;nbsp; i use autocad 2010, there is no ed.Command method.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 00:52:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283300#M36319</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-21T00:52:48Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283510#M36320</link>
      <description>&lt;P&gt;In my first reply, I gave you a &lt;A href="https://forums.autodesk.com/t5/net/send-command-executes-after-exiting-command-method/td-p/3882929" target="_blank"&gt;link&lt;/A&gt; to a topic where DinningPhilosopher (aka Tony Tanzillo) provided a wrapper for the undocumented RunCommand() method. You can also search for acedCmd P/Invoking methods.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 05:46:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283510#M36320</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-04-21T05:46:43Z</dc:date>
    </item>
    <item>
      <title>Re : how to load a dll and run the command by a method in a command?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283715#M36321</link>
      <description>&lt;P&gt;Hi yuan:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Your words solve my problem, thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; First I use 'ExtensionLoader' to load the dll. And use 'AppDomain.CurrentDomain.GetAssemblies()' to get the 'Assembly'. Then I can run the command method now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; By the way, the 'ExtensionLoader' class is available in acad2010.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 07:57:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-load-a-dll-and-run-the-command-by-a-method-in-a-command/m-p/6283715#M36321</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-04-21T07:57:53Z</dc:date>
    </item>
  </channel>
</rss>

