How to: Install and Develop with Visual Studio Tools for Applications
You can greatly enhance the functionality of your InfoPath forms by extending them with managed code developed in Microsoft Visual Studio Tools for Applications, a programming environment that can be installed with the Microsoft InfoPath 2010. You can then publish your forms with code to form libraries on Microsoft SharePoint Server 2010.
You can start programming and deploying your InfoPath forms with managed code in three high-level steps:
Install the prerequisites that you need to run Microsoft Visual Studio Tools for Applications and develop forms with code.
After the prerequisites and Microsoft Visual Studio Tools for Applications are installed, you can start InfoPath, set your programming language, start Microsoft Visual Studio Tools for Applications, and then start to write code.
When you have finished designing the form and developing your code, the form template can be published to SharePoint Server 2010.
You should consider creating forms that are compatible with SharePoint Server 2010 for the following reasons.
Form deployed to SharePoint Server 2010 with InfoPath Forms Services can be filled out in a browser. This enables users who do not have InfoPath installed to open and run your forms.
You have to design only one version of the form. Forms that are compatible with Microsoft SharePoint Server are also compatible with the InfoPath Filler, but forms that are compatible only with the InfoPath Filler cannot be opened in the browser.
There are two ways to publish your form to SharePoint: SharePoint sandboxed solutions, and administrator-deployed solutions. For information about each publication method and suggestions about which method is best for your scenario, see Publishing Forms with Code. For example solutions that demonstrate scenarios for sandboxed solutions, see Sample Sandboxed Solutions.
The following sections describe how to install the Microsoft .NET Framework prerequisites that are required to install and run the Microsoft Visual Studio Tools for Applications programming environment.
Microsoft .NET Framework
The minimum version of the Microsoft .NET Framework required to program in InfoPath 2010 is Microsoft .NET Framework 2.0. If your computer meets this system requirement, then you can work with Microsoft Visual Studio Tools for Applications, .NET 2.0 libraries, and the whole InfoPath object model provided by the members of the Microsoft.Office.InfoPath namespace.
However, you may also want to develop with the SharePoint Server 2010 object model and some newer .NET libraries. It is recommended that, as a form code developer, you install Microsoft .NET Framework 3.5. Installing Microsoft .NET Framework 3.5 will install the complete .NET stack starting with version 1.1, and the linked topics that provide examples use libraries from each version of the .NET Framework.
The Microsoft .NET Framework 3.5 can be downloaded from the Microsoft Download Center.
Visual Studio Tools for Applications
Microsoft Visual Studio Tools for Applications is an optional component that is included in the Microsoft Office InfoPath section of the Microsoft Office 2010 setup application. Microsoft .NET Framework 2.0 or a later version must be installed before Microsoft Visual Studio Tools for Applications can be installed. To install Microsoft Visual Studio Tools for Applications, start Microsoft Office 2010 setup, and then under Microsoft Office InfoPath, set Visual Studio Tools for Applications to Run from My Computer.
Now that Microsoft Visual Studio Tools for Applications is installed, you are ready to start to develop InfoPath managed code solutions.
Choosing a Programming Language
InfoPath 2010 provides the options to program by using three versions of the InfoPath object model in two languages: Visual Basic and C#. The three versions of the object model provide compatibility with InfoPath 2010, Office InfoPath 2007, and Microsoft InfoPath 2003.
To specify the programming language and object model
With a form template project open in the InfoPath designer, click Language on the Developer tab.
In the Programming category of the Form Options dialog box, select the language that you want to work with from the Form template code language drop-down list. Language options that use an object model that is compatible with an earlier version of InfoPath are followed by either "InfoPath 2007 Compatible" or "InfoPath 2003 Compatible." The language options that are compatible only with InfoPath 2010 do not have anything following the C# or Visual Basic language name.
Not all form template types support code. For example, the SharePoint List form template type and Template Parts do not support form code. When designing a form template type that does not support code, the Developer tab will not be available. Also, only some form template types support all three versions of the object object model. For example, the Blank (InfoPath Form Filler) template type supports all three versions of the object model (and creates form template that are compatible only with the InfoPath Filler in those versions), but the Blank form template supports only InfoPath 2010 and Office InfoPath 2007 (and creates form templates that are compatible with both the InfoPath Filler and the browser).
You can set a default programming language so that the InfoPath form designer will always start with the language and object model version of your choice.
To set the default programming language
Click the File tab, and then click Options.
In the General section of the InfoPath Options dialog box, click More Options.
On the Design tab of the Options dialog box, select the default programming language in the Programming Defaults section.
Starting Visual Studio for Applications
You can now start to develop with Microsoft Visual Studio Tools for Applications.
To start the Visual Studio for Applications Code Editor
Open a form template in the InfoPath designer.
Click Code Editor on the Developer tab.
You can also start Microsoft Visual Studio Tools for Applications and automatically add event handlers for form and control events using commands on the Developer tab, context menus, and other user interface methods. For more information, see How to: Add an Event Handler