Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


Keywords: KB922210, kbprb, kbtshoot

↑ Back to the top

Article Info
Article ID : 922210
Revision : 5
Created on : 2/7/2007
Published on : 2/7/2007
Exists online : False
Views : 238