<?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: dll loaded success, but Initialize doesn't work in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226679#M12701</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;A project referencing AutoCAD 2012 libraries (AcDbMgd.ll and AcMgd.dll) won't work on later versions. You have to build a new project referencing AcCoreMgd.dill, AcDbMgd.ll and AcMgd.dll from AutoCAD 2013 or later libraries.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2022 09:08:31 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2022-06-10T09:08:31Z</dc:date>
    <item>
      <title>dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226522#M12700</link>
      <description>&lt;P&gt;I use the netload command to load my dll, but the code in MyApp.Initialize() doesn't execute and my command doesn't work. This problem does not appear on the cad2012 version, but sometimes it occurs in the cad2016,2018,2020 version.&lt;/P&gt;&lt;P&gt;If I build new project, this problem does not appear.&lt;/P&gt;&lt;P&gt;So what's wrong with my project？&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

[assembly: ExtensionApplication(typeof(MyNamespace.MyApp))]
namespace MyNamespace{
public class MyApp : IExtensionApplication
{
    public void Initialize()
    {
        Document doc = Application.DocumentManager.MdiActiveDocument;
        Editor ed = doc.Editor;
        ed.WriteMessage("MyDll load success");
    }

    //...other code
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 08:01:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226522#M12700</guid>
      <dc:creator>adn019LKFW</dc:creator>
      <dc:date>2022-06-10T08:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226679#M12701</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;A project referencing AutoCAD 2012 libraries (AcDbMgd.ll and AcMgd.dll) won't work on later versions. You have to build a new project referencing AcCoreMgd.dill, AcDbMgd.ll and AcMgd.dll from AutoCAD 2013 or later libraries.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 09:08:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226679#M12701</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-06-10T09:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226702#M12702</link>
      <description>&lt;P&gt;Thank you for your reply,&lt;/P&gt;&lt;P&gt;I'm using different project for each cad version, and both correctly reference the corresponding version of the dlls.&lt;/P&gt;&lt;P&gt;So it doesn't look like the problem is caused by this reason.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 09:25:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226702#M12702</guid>
      <dc:creator>adn019LKFW</dc:creator>
      <dc:date>2022-06-10T09:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226715#M12703</link>
      <description>&lt;P&gt;You have to compare Application.DocumentManager.MdiActiveDocument and null before call doc.Editor.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 09:33:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226715#M12703</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2022-06-10T09:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226734#M12704</link>
      <description>&lt;P&gt;Thank you for your reply,&lt;/P&gt;&lt;P&gt;I'm sure &lt;SPAN&gt;Application.DocumentManager.MdiActiveDocument&amp;nbsp;&lt;/SPAN&gt;is not null.&lt;/P&gt;&lt;P&gt;I try to attach to acad.exe in debug mode,&amp;nbsp; Initialize() is not invoked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 09:57:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226734#M12704</guid>
      <dc:creator>adn019LKFW</dc:creator>
      <dc:date>2022-06-10T09:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226874#M12705</link>
      <description>&lt;P&gt;In addition to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt; said, you should also handle the Apllication.Idle event.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        public void Initialize()
        {
            Application.Idle += OnIdle;
        }

        private void OnIdle(object sender, EventArgs e)
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            if (doc != null)
            {
                Application.Idle -= OnIdle;
                doc.Editor.WriteMessage("\nMyDll load success.\n");
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 Jun 2022 10:57:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11226874#M12705</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-06-10T10:57:45Z</dc:date>
    </item>
    <item>
      <title>回复： dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11227084#M12706</link>
      <description>&lt;P&gt;I rebuild the project a few times without any modification and it works. It's so weird.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 12:36:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11227084#M12706</guid>
      <dc:creator>adn019LKFW</dc:creator>
      <dc:date>2022-06-10T12:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11228284#M12707</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;You have to compare Application.DocumentManager.MdiActiveDocument and null before call doc.Editor.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I remember seeing something like this in&lt;STRONG&gt; Helper.cs&lt;/STRONG&gt;.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;..\Autodesk\ObjectARX_for_AutoCAD_2023_Win_64bit_dlm\samples\dotNet\EventsWatcher&lt;/LI-CODE&gt;&lt;LI-CODE lang="csharp"&gt;try
{
	// Application.DocumentManager.Count should be used to check zero doc status
	// MdiActiveDocument returns non null sometimes even if in zero doc status!
	if(	Application.DocumentManager.MdiActiveDocument != null
		&amp;amp;&amp;amp; Application.DocumentManager.Count != 0)
		Helper.CmdLineMessage(str);
	else
		Helper.InfoMessageBox(str);

	Helper.StreamToRichTextControl(str);
}
catch (System.Exception ex)
{
	Helper.Message(ex);
}&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// Application.DocumentManager.Count should be used to check zero doc status&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;// MdiActiveDocument returns non null sometimes even if in zero doc status!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Possible why it was working and then not working no? Should possible consider adding to avoid the error in the future.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 11 Jun 2022 00:16:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11228284#M12707</guid>
      <dc:creator>CadWCCNL</dc:creator>
      <dc:date>2022-06-11T00:16:23Z</dc:date>
    </item>
    <item>
      <title>回复： dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11228514#M12708</link>
      <description>&lt;P&gt;My problem is that Initialize() is not invoked after netload, and commands in this project are not registered, Editor.WriteMessage() is just an example added here.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2022 06:18:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11228514#M12708</guid>
      <dc:creator>adn019LKFW</dc:creator>
      <dc:date>2022-06-11T06:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: dll loaded success, but Initialize doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11256829#M12709</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9394256"&gt;@adn019LKFW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Remove&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[assembly: ExtensionApplication(typeof(MyNamespace.MyApp))]&lt;/PRE&gt;&lt;P&gt;It should work as expected!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:35:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/dll-loaded-success-but-initialize-doesn-t-work/m-p/11256829#M12709</guid>
      <dc:creator>varshaauti27</dc:creator>
      <dc:date>2022-06-24T15:35:33Z</dc:date>
    </item>
  </channel>
</rss>

