Author Topic: Reactors/Events  (Read 9299 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Reactors/Events
« Reply #15 on: April 12, 2007, 09:00:24 PM »
Upon a lot deeper investigation, it appears that there was a VERY quiet error being thrown deep in my code, eNotNewlyCreated and also, IExtensionApplication's Initialize() method is being called TWICE for the same dll!!!!

More investigation...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reactors/Events
« Reply #16 on: April 12, 2007, 09:01:46 PM »
[irreverent reply]
time for a Bourbon.
[/irreverent reply]
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: Reactors/Events
« Reply #17 on: April 12, 2007, 09:04:49 PM »
Tell me about it...it's got me stuffed! Initialize() firing twice for the same dll............

Glenn R

  • Guest
Re: Reactors/Events
« Reply #18 on: April 12, 2007, 09:17:11 PM »
<mutter, splutter> Bloody typing mistake! Grrrr, I hate that. My apologies Tony, everything seems to be working well. I do think typos are one of the hardest bugs to find.

I was creating a dictionary heirarchy in a transaction (company dict and application dict) and where I should have used a newly created app dict in a transaction AddNewLyCreatedObjects call, I was actually passing in the existing company dict, which for some strange reason caused Initialize to fire again and the second time through it would throw an eNotNewlyCreated error.

TonyT

  • Guest
Re: Reactors/Events
« Reply #19 on: April 13, 2007, 11:27:11 AM »
Hi Glenn.

I have also seen Initialize() fire more than once.

The way to deal with the possiblity that it will
happen, is to use the static constructor on the
class that implements IExtensionApplication,
as that method will never be called more than
once:

Code: [Select]
public class MyApplication : IExtensionApplication
{
 
   static MyApplication()
   {
      ExtensionApplicationInfo.Register();
   }

  #region IExtensionApplication Members

   public void Initialize()
   {
        // instead of doing one-time initialization
        // here, do it in the static c'tor
   }

   public void Terminate()
   {
   }

   #endregion
}


<mutter, splutter> Bloody typing mistake! Grrrr, I hate that. My apologies Tony, everything seems to be working well. I do think typos are one of the hardest bugs to find.

I was creating a dictionary heirarchy in a transaction (company dict and application dict) and where I should have used a newly created app dict in a transaction AddNewLyCreatedObjects call, I was actually passing in the existing company dict, which for some strange reason caused Initialize to fire again and the second time through it would throw an eNotNewlyCreated error.
« Last Edit: April 14, 2007, 12:57:37 AM by TonyT »

Glenn R

  • Guest
Re: Reactors/Events
« Reply #20 on: April 15, 2007, 07:29:09 PM »
Hi Tony,

The static constructor would have been my next option, but having traced it to a typo, I didn't go further.
Interestingly, there was no try/catch blocks in the code and it was still a 'quiet' error...I'm suspecting AutoCAD's Transaction mechanism, coupled with how Acad calls Initialize() in classes, is the culprit here...

Cheers,
Glenn.

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: Reactors/Events
« Reply #21 on: February 16, 2013, 07:22:53 AM »
a 'quiet' error...I'm suspecting AutoCAD's Transaction mechanism, coupled with how Acad calls Initialize() in classes, is the culprit here...

from the "better late than never department" - http://drive-cad-with-code.blogspot.com.au/2012/12/black-hole-in-iextensionapplication.html