Export (0) Print
Expand All

Understanding InfoPath 2007 Object Models and Development Environments

Microsoft Office InfoPath 2007 supports three kinds of programming models for developing business logic in form templates, and also supports external automation from managed code.

Microsoft Office Forms Server 2007 and the same forms functionality called InfoPath Forms Services available in Microsoft Office SharePoint Server 2007 provide an object model for automating server tasks.

Office InfoPath 2007 supports three development environments and several programming languages, which are described later in this topic. Which development environment you use depends in part on which programming model you need to work with.

InfoPath Programming Models

Office InfoPath 2007 supports three object models for developing business logic in form templates:

  • The COM and Scripting Object Model

  • The InfoPath 2003-Compatible Managed Code Object Model

  • The New InfoPath Managed Code Object Model

Additionally, Office InfoPath 2007 provides a way of writing managed code to automate InfoPath from an external application.

Microsoft Office Forms Server 2007 and InfoPath Forms Services provide an object model for automating server tasks, such as verifying and uploading form templates from code running on the server, which requires server administrator access and permissions.

The COM and Scripting Object Model

The COM and Scripting object model is implemented in the following dynamic link library (*.dll) files which are located in the C:\Program Files\Microsoft Office\Office12 folder:

Dynamic Link Library Description

IPEDITOR.DLL

Provides the COM-based object model for the InfoPath form editing runtime. Exposes objects and members that can be called from business logic written in JScript or VBScript. Also exposes methods of the Application object and XDocuments collection that can be called from COM components and applications to automate the InfoPath application.

IPDESIGN.DLL

Provides COM-based interfaces for creating custom form converters, and the ExcelImporter and the WordImporter objects for creating new InfoPath form templates by importing the design of forms created in Excel and Word.

NoteNote:

Although creating business logic with scripting languages (JScript and VBScript) against the COM and Scripting object model is still supported by the InfoPath client, business logic written in script is not supported for browser-enabled form templates deployed to Office Forms Server 2007 or Microsoft Office SharePoint Server 2007 with InfoPath Forms Services. Browser-enabled form templates must use the new InfoPath managed code object model for custom business logic.

For more information about working with script and COM automation, see the InfoPath Developer Reference documentation which is available by clicking Microsoft Office InfoPath Help on the Help menu in Office InfoPath 2007.

The InfoPath 2003-Compatible Managed Code Object Model

The InfoPath 2003-compatible managed code object model was first introduced in InfoPath 2003 Service Pack 1 in conjunction with the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET for writing business logic in form templates with managed code. This object model is still supported by Office InfoPath 2007 to provide compatibility with InfoPath 2003.

The classes and members of this object model are exposed through the Microsoft.Office.Interop.InfoPath.SemiTrust namespace. This object model is implemented in the following assembly file which is located in the C:\Program Files\Microsoft Office\Office12 folder:

Assembly Description

Microsoft.Office.Interop.InfoPath.SemiTrust.dll

Provides COM interop against the InfoPath COM object model for form template business logic written using C# or Visual Basic .NET.

NoteNote:

Although creating business logic with the COM interop managed-code object model provided by the Microsoft.Office.Interop.InfoPath.SemiTrust assembly is still supported by Office InfoPath 2007, business logic written using this object model it is not supported for browser-enabled form templates deployed to Office Forms Server 2007 or Microsoft Office SharePoint Server 2007 with InfoPath Forms Services. Browser-enabled form templates must use the new InfoPath managed code object model for custom business logic.

NoteNote:

When you create a form template project that is compatible with InfoPath 2003 (by setting the Form template code language to C# (InfoPath 2003 Compatible) or Visual Basic (InfoPath 2003 Compatible) under the Programming category in the Form Options dialog box), by default all calls will be to members of the Microsoft.Office.Interop.InfoPath.SemiTrust namespace that are backwardly compatible. However, if it no longer necessary to be backwardly compatible, you can use new object model members in the Microsoft.Office.Interop.InfoPath.SemiTrust namespace. For more information, see How to: Use Microsoft.Office.Interop.InfoPath.SemiTrust Members That Are Not Compatible with InfoPath 2003.

The New InfoPath Managed Code Object Model

A new InfoPath managed code object model is implemented in two assemblies both of which are named Microsoft.Office.Infopath.dll.

One version of the assembly implements a subset of the InfoPath object model that contains only the types and members that are supported in the business logic of form templates deployed as browser-enabled form templates running on Office Forms Server 2007 or Microsoft Office SharePoint Server 2007 with InfoPath Forms Services. Form templates with business logic written against this assembly will open and run in InfoPath and in a Web browser.

The other version of the assembly implements the full InfoPath object model which contains additional types and members that provide functionality that is not supported in the business logic of browser-enabled form templates. Form templates with business logic written against the InfoPath-specific classes and members in this assembly will open and run only in InfoPath.

NoteNote:

It is possible to write conditional logic that uses the properties of the Environment class to determine which environment (InfoPath or a Web browser) the form template is running in. Using this conditional logic, your business logic can branch between code that works in a Web browser and code written against classes and members that work only in InfoPath. For more information, see How to: Write Conditional Logic That Determines the Run-time Environment

The assembly that InfoPath uses when adding and compiling business logic for the form template depends on whether you select the Enable browser-compatible features only check box in the Design a Form dialog box when you start designing a new form. Alternatively, you can change this setting in the Form Options dialog box in the Compatibility category by selecting or clearing the Design a form template that can be opened browser or InfoPath check box.

The classes and members of both versions of this object model are exposed through the Microsoft.Office.InfoPath namespace. These assemblies are located in the following directories of an Office InfoPath 2007 installation:

Assembly Description

Microsoft.Office.InfoPath.dll
(located in C:\Program Files\Microsoft Office\Office12\InfoPathOM)

The subset of the object model that contains only types and members that will run in the business logic of a form template deployed to a server running InfoPath Forms Services. (Enable browser-compatible features only check box or Design a form template that can be opened browser or InfoPath check box is selected)

Microsoft.Office.InfoPath.dll
(located in C:\Program Files\Microsoft Office\Office12\)

The "full" object model including types and members that will not run in the business logic of a form template deployed to Office Forms Server 2007. (Enable browser-compatible features only check box or Design a form template that can be opened browser or InfoPath check box is not selected)

NoteNote:

The assemblies referenced above are used at design time when writing and compiling code. At run time, the assembly used when a form template is opened in InfoPath is located in the Global Assembly Cache (GAC) of the computer on which InfoPath is installed. When a form template is opened in a Web browser from a server running InfoPath Forms Services, the assembly used is located on the server.

Providing two assemblies helps ensure that your business logic will contain only calls to the appropriate object model members for the supported form editors (Web browser or InfoPath). For example, when editing your code, IntelliSense features such as statement completion and in-line documentation will only display and work against the appropriate object model members for your target editor or editors.

In both versions of the new managed code object model exposed by the Microsoft.Office.InfoPath assembly, navigating and updating XML data stores in business logic requires calls to the members of the System.Xml.XPath.XPathNavigator class. In InfoPath 2003, navigating and updating XML data stores requires calling members of MSXML 5.0 classes (for business logic created with JScript or VBScript) or by calling through the wrappers for MSXML 5.0 classes provided by the Microsoft.Office.Interop.InfoPath.SemiTrust namespace (for business logic created with C# or Visual Basic and the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET).

Using members of the XPathNavigator class allows the same business logic code to support DOM manipulation for form templates that are opened in both the InfoPath client and in Web-enabled forms opened from the Office Forms Server 2007 or from Microsoft Office SharePoint Server 2007 with InfoPath Forms Services in a Web browser.

For information on working with members of the XPathNavigator class in the business logic of InfoPath managed code form templates, see How to: Work with the XPathNavigator and XPathNodeIterator Classes.

Automating InfoPath from Managed Code

In addition to writing business logic with managed code, it is possible to automate InfoPath by using managed code running in an external application. This functionality and the assemblies required for writing code were first introduced in InfoPath 2003 Service Pack 1. The objects and members for automating InfoPath have been updated to provide additional functionality when writing external automation code for Office InfoPath 2007.

The classes and members used for external automation are exposed through the Microsoft.Office.Interop.InfoPath and Microsoft.Office.Interop.InfoPath.Xml namespaces. The assembly files required for writing automation code are located in the C:\Program Files\Microsoft Office\Office12 folder:

Assembly Description

Microsoft.Office.Interop.InfoPath.dll

Provides COM interop against the InfoPath COM object model for external automation code written using C# or Visual Basic .NET.

Microsoft.Office.Interop.InfoPath.Xml.dll

Provides COM interop against the MSXML 5.0 for XML DOM operations in external automation code written using C# or Visual Basic .NET.

For information on the object models provided by the Microsoft.Office.Interop.InfoPath and Microsoft.Office.Interop.InfoPath.Xml namespaces, which are used exclusively to automate the InfoPath application using managed code from external applications, see "Automating InfoPath from Other Applications" in the documentation that is installed with Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System.

The Office Forms Services Object Model

The managed code object model for automating Office Forms Server 2007 or InfoPath Forms Services administration tasks is implemented in the Microsoft.Office.InfoPath.Server.dll which is located at <drive>:\Program Files\Microsoft Office Server\12.0\Bin on an Office Forms Server 2007 or Microsoft Office SharePoint Server 2007 installation:

Assembly Description

Microsoft.Office.InfoPath.Server.dll

The object model for automating Office Form Server tasks such as uploading, activating, or deactivating browser-enabled form templates.

For more information on the Office Forms Services object model, see the Microsoft Office Forms Server 2007 Software Developers Kit (SDK) which is available on MSDN.

InfoPath Development Environments

The development of business logic in Office InfoPath 2007 form templates can be performed by using one of three development environments:

  • Microsoft Script Editor

  • Microsoft Visual Studio Tools for Applications (VSTA)

  • InfoPath design mode integration using Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, or Visual Studio 2008 with Visual Studio Tools for Office

Which development environment you use depends, in part, on which programming language and which object model your business logic is written against. Information to help you determine which development environment to use is provided in the following sections.

Microsoft Script Editor (MSE)

As was the case for InfoPath 2003, to write business logic using JScript or VBScript code written against the InfoPath COM object model, you use the Microsoft Script Editor (MSE), which is installed and integrated with the Office InfoPath 2007 application by default. The features of this development environment are essentially the same as those in InfoPath 2003. To develop business logic using JScript or VBScript in MSE, open the form template in design mode. Open the Form Options dialog box, select the Programming category, and then set the Programming language of the form template to either JScript or VBScript.

Visual Studio Tools for Applications (VSTA)

If your computer has Microsoft .NET Framework 2.0 and Microsoft Core XML Services (MSXML) 6.0 installed, the Microsoft Visual Studio Tools for Applications (VSTA) development environment can be installed along with Office InfoPath 2007. If you did not have the Microsoft .NET Framework 2.0 and MSXML6 components installed when you first installed InfoPath, you must download and install those components before you can use the VSTAdevelopment environment. (Microsoft .NET Framework 2.0 is available as an optional software update on Windows Update, and MSXML6 is available from the MSDN web site.)

The VSTA development environment is not installed by default when you choose Typical to install InfoPath. To install VSTA, you must either choose Customize when first installing, or use Add or Remove Programs to update your Office or InfoPath installation to include VSTA. The option to install VSTA is available by expanding Microsoft Office InfoPath, .NET Programmability Support, and .NET Programmability Support for .NET Framework version 2.0.

The VSTA environment can be used to write business logic in C# or Visual Basic against either the InfoPath 2003-compatible object model (members of the Microsoft.Office.Interop.InfoPath.SemiTrust namespace) or the new managed code object model (members of the Microsoft.Office.InfoPath namespace).

NoteNote:

Although the Visual Studio Tools for Applications environment requires MSXML6 for installation, InfoPath form templates and the InfoPath editor depend only on MSXML5.

InfoPath Design Mode Integration in Visual Studio

A new feature of Visual Studio Tools for Office is that the Office InfoPath 2007 form template design environment can now be fully integrated into the Visual Studio development environment. You can work with the features of Office InfoPath 2007 to design the look of your form template at the same time that you write managed code to extend its capabilities without leaving Visual Studio.

The InfoPath form designer features can be integrated into Visual Studio 2005 by installing Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, which can be downloaded from the InfoPath Developer Portal on MSDN. Before installing Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, you must have Visual Studio 2005 and Office InfoPath 2007 installed. Alternatively, you can use Visual Studio 2008 with Visual Studio Tools for Office.

This development environment can be used to write business logic in C# or Visual Basic against either the COM interop object model (members of the Microsoft.Office.Interop.InfoPath.SemiTrust namespace) or the new managed code object model (members of the Microsoft.Office.InfoPath namespace).

Maintaining, Creating, and Converting Form Templates That Work with the InfoPath 2003 Object Model

VSTA and the InfoPath design mode integration with Visual Studio development environments for Office InfoPath 2007 let you open and continue to work on InfoPath form template projects created with the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET or with Visual Studio 2005 Tools for the Microsoft Office System.

NoteNote:

Users of form templates compiled with VSTA, Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, or Visual Studio 2008 with Visual Studio Tools for Office must have Microsoft .NET Framework 2.0 installed on their computers. Whereas users of form templates compiled with Visual Studio .NET 2003 only require Microsoft .NET Framework 1.1 on their computers.

You can also use either development environment to create new managed code form template projects that work with the InfoPath 2003 object model to retain backward compatibility with InfoPath 2003. To use these development environments and maintain backward compatibility, create a new form template, click Form Options on the Tools menu, and then in the Programming category choose either C# (InfoPath 2003 Compatible) or Visual Basic (InfoPath 2003 Compatible) as the form template code language.

Additionally, you can convert a form template that works with the InfoPath 2003 object model to use the new InfoPath managed code object model. For information on converting form templates, see How to: Open or Convert a Form Template Created with the InfoPath Toolkit or Script.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft