Showing results for 
Search instead for 
Did you mean: 

Instantiation of viewers



Does anyone have any information about controlling how viewers are instantiated?


The reason I'm interesteted is that I want to use the TxApplication.DocumentCollection.DocumentLoaded event from within a viewer, and it fires twice when I load a document, which seems to be caused by the fact there are two instances of the viewer. If I close the viewer but keep it available via a reference in an XML file under DotNetExternalApplications it still fires, but only once. It seems there is a "ghost" instance of the viewer which is instatiated at start-up but is not visible. The second, visible, instance is created when the viewer is opened (which will be shortly afterwards if the viewer is visible at start-up).


The event I intend to run could be fairly time-consuming, so avoiding a double run would be a big advantage. Is there any way I can prevent the ghost instance, of at least detect that it is the ghost instance and mask out the time-consuming process for this instance?


Any help would be appreciated.


Best Regards,




Re: Instantiation of viewers

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi  Cypherspaceman,


The viewers are instantiated twice - once to get their resources, like name and description, when the application loads and once when you open them. I guess you register to the event in the constructor of the viewer. The right place to register and unregister to application events is in Initialize/Uninitialize methods. Each is called only once when viewer opens and closes.


Best Regards,


Re: Instantiation of viewers

Ah, that makes sense - you were right, I was registering in the constructor.

I should probably apply that principle to other viewers.

Thanks for your help.