Tony,
I've been playing with your DocumentDataObject class and I'm getting some odd behaviour.
I have 2 projects - one that watches when save and layout events happen and another when certain sysvars are changed and layout events occur. I had these working with the method/classes I posted earlier in this thread, but then decided to retro-fit them and use yours.
Both of these projects are demand loaded through registry entries and whichever is in first works, the second in doesn't have any of it's events fire.
I thought I had traced it down to this:
if(instanceType != null)
return;
The debugger was showing the second dll hitting this line and returning out. I suspected this was because for some strange reason the first dll had already set instanceType...but that doesn't really make sense.
It get's even more strange. I then ripped out your factory and went back to old faithful, but yesterday I decided to play again.
I created 2 test projects, both using your class factory - one watched when the TILEMODE sysvar changed and the other BeginSave.
To make sure they were working I put in print statements to the commandline inside the event handlers of both.
I then manually loaded both into 2006 and they both worked! I sat there scratching my head and decided maybe I had screwed up on my last attempt and everything was good, so I worte another program yesterday and decided to give DocumentDataObject another bash, leaving my classes intact.
So, I have a 2 dll's loaded that both watch sysvars and whatnot - one uses my way of doing this and the other yours - The one in first still works and the one in second still fails. The only thing they have in common is that in the Initialize method of IExtensionApplication they both do this:
LayoutManager.Current.LayoutCreated += OnLayoutCreated;
LayoutManager.Current.LayoutToBeRenamed += new LayoutRenamedEventHandler(OnLayoutToBeRenamed);
LayoutManager.Current.LayoutCopied += new LayoutCopiedEventHandler(OnLayoutCopied);
LayoutManager.Current.LayoutRemoved += new LayoutEventHandler(OnLayoutRemoved);
It's the only common thing between them. Any thoughts?