<?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 Is it safe to use Database in the Initialize() method? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/is-it-safe-to-use-database-in-the-initialize-method/m-p/5636779#M40025</link>
    <description>&lt;P&gt;When I do it, then my code looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public void Initialize() {
  Document doc = cad.DocumentManager.MdiActiveDocument;
  if (null == doc)
    return;
 
  Database db = doc.Database;
  Editor ed = doc.Editor;
 
  using (doc.LockDocument()) {
    using (Transaction tr = db.TransactionManager.StartTransaction()) {
      ed.WriteMessage("\nThe \"{0}\" assembly successfully loaded.\n",
        this.GetType().Assembly.Location);      
      // TODO: Here is my code of working with Database...
      tr.Commit();
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Assembly can be registered for autoloading (through the registry record or BUNDLE engine). I hadn't problems with such approach, but I remember - Alexander Rivilis wrote he had. He wrote what the Document (or Database) can be initialized not completely at the time of operation of this code. Ok, how can I check initialization of these objects was finished?&lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2015 14:09:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-05-15T14:09:03Z</dc:date>
    <item>
      <title>Is it safe to use Database in the Initialize() method?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-it-safe-to-use-database-in-the-initialize-method/m-p/5636779#M40025</link>
      <description>&lt;P&gt;When I do it, then my code looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public void Initialize() {
  Document doc = cad.DocumentManager.MdiActiveDocument;
  if (null == doc)
    return;
 
  Database db = doc.Database;
  Editor ed = doc.Editor;
 
  using (doc.LockDocument()) {
    using (Transaction tr = db.TransactionManager.StartTransaction()) {
      ed.WriteMessage("\nThe \"{0}\" assembly successfully loaded.\n",
        this.GetType().Assembly.Location);      
      // TODO: Here is my code of working with Database...
      tr.Commit();
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Assembly can be registered for autoloading (through the registry record or BUNDLE engine). I hadn't problems with such approach, but I remember - Alexander Rivilis wrote he had. He wrote what the Document (or Database) can be initialized not completely at the time of operation of this code. Ok, how can I check initialization of these objects was finished?&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 14:09:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-it-safe-to-use-database-in-the-initialize-method/m-p/5636779#M40025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-15T14:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is it safe to use Database in the Initialize() method?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-it-safe-to-use-database-in-the-initialize-method/m-p/5636889#M40026</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it seems this matches your "problem": &lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2013/01/displaying-a-dialog-on-autocad-startup-using-net.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2013/01/displaying-a-dialog-on-autocad-startup-using-net.html&lt;/A&gt; &lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://forums.autodesk.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least in the introduction Kean wrote the sentence: "[...]he needed to display a dialog on AutoCAD startup, but found that it was too soon to do so on IExtentionApplication.Initialize()[...]".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 14:49:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-it-safe-to-use-database-in-the-initialize-method/m-p/5636889#M40026</guid>
      <dc:creator>max.senft</dc:creator>
      <dc:date>2015-05-15T14:49:35Z</dc:date>
    </item>
  </channel>
</rss>

