Article ID: 922210 - Last Review: February 7, 2007 - Revision: 1.4

The XDocumentBeforeClose event does not occur when you exit InfoPath 2007 without first closing a form

Expand all | Collapse all

SYMPTOMS

Consider the following scenario:
  • You design a new Microsoft Visual C# Add-in project for Microsoft Office InfoPath 2007.
  • You use the following code example to change the OnConnection event method. This code example also changes the applicationObject definition to Private ApplicationClass applicationObject;.
    applicationObject = (ApplicationClass)application;
    	addInInstance = addInInst;
    
                ((ApplicationEventsClass)applicationObject.Events).XDocumentBeforeClose += new 			_ApplicationEvents_XDocumentBeforeCloseEventHandler(Connect_XDocumentBeforeClose);
    
    
  • You add a method definition that resembles the following code example.
    void Connect_XDocumentBeforeClose(_XDocument pDocument, ref bool pfCancel)
            	{
    	            System.Windows.Forms.MessageBox.Show("Connect_XDocumentBeforeClose");
            	}
  • You build and install the new add-in.
  • You open the form in InfoPath 2007.
  • You exit InfoPath 2007 without first closing the form.
In this scenario, the XDocumentBeforeClose event does not occur.

CAUSE

This behavior occurs because the XDocumentBeforeClose event may prevent InfoPath 2007 to shut down by returning "fCancel=true". However, if the XDocumentBeforeClose event is called, the event is ignored, and the returned value may confuse some third-party developers. Therefore, use the Application::Quit command if you must perform cleanup tasks related to opened documents.

STATUS

This behavior is by design.

APPLIES TO
  • Microsoft Office InfoPath 2007
Keywords: 
kbtshoot kbprb KB922210
 

Article Translations

 

Related Support Centers