共用方式為


About InfoPath Forms Services and Business Logic Assemblies

Applies to: SharePoint Server 2010

In this article
The New Managed Code Object Model
Security and Performance
Notes About Using and Referencing Assemblies

Custom business logic is supported in a browser-enabled form template if it uses the supported types and members of the new managed code object model provided by the Microsoft.Office.InfoPath namespace. The Microsoft Visual Studio Tools for Applications development environment integrated with the InfoPath Designer provides support for the Visual Basic and Visual C# languages.

JScript, VBScript, and managed code written by using the Microsoft.Office.Interop.InfoPath.SemiTrust object model that was introduced with Microsoft Office InfoPath 2003 with Service Pack 1, are not supported on a server running InfoPath Forms Services.

The New Managed Code Object Model

The new managed code object model uses the [System.Xml.XPath.XPathNavigator] class for navigating and updating XML data stores, and the Microsoft SharePoint Foundation technology that InfoPath Forms Services is built upon requires the .NET Framework 2.0. For detailed information about the new managed code object model and the deprecated object models that can be used with Microsoft InfoPath 2010, see the "Understanding InfoPath Object Models and Development Environment" topic located in the InfoPath 2010 Developer Reference for Form Templates, which is available within the Microsoft Visual Studio Tools for Applications Help system.

For more information about the subset of the new managed code object model that contains the types and members that can be used in both InfoPath and in a Web browser, see Design-Once Feature Compatibility. It is possible to programmatically determine the runtime environment in order to change custom business logic based on whether the form is opened in InfoPath, a desktop Web browser, or on a mobile browser. For more information about determining the runtime environment, see the "How to: Write Conditional Logic That Determines the Run-time Environment" topic located in the Microsoft Visual Studio Tools for Applications Help system.

Security and Performance

When you create a browser-compatible form template, the default InfoPath form code file will be signed with the InfoPath.snk strong name key file. You can use a different strong-named key file for your business logic assemblies. If the default form code file or any supporting assemblies are not strong-named and signed and the form template that contains the business logic assembly is upgraded, the SharePoint Application Domain (AppDomain) must be recycled.

InfoPath business logic assemblies are granted permissions through the Code Access Security (CAS) policy resolution. The domain-new trust level on the server is an equivalent concept to the domain trust level on the client. SharePoint includes three policy files: Minimal, Medium, and Full. InfoPath Forms Services gives business logic assemblies corresponding evidence so they map to a code group that is defined in the policy file and get the correct permission set. This permission set is given to the business logic assembly when it is loaded into the ASP.NET Application Domain, but in most cases will not be exactly what the same assembly will receive when the form template that contains the custom business logic assembly is opened in InfoPath. In order to ensure that a form template can be opened in InfoPath and in a browser, when a business logic assembly makes object model calls or when InfoPath Forms Services sends events to the business logic assembly, the permission set is elevated or reduced as appropriate to achieve the correct level. Furthermore, if an InfoPath form template contains multiple assemblies, all assemblies are loaded at the same time to ensure a consistent permission set is applied.

Note

Only Full Trust form templates can contain code that dynamically creates assemblies on a server that is running InfoPath Forms Services.

Every business logic assembly from all browser-enabled form templates on servers that are running InfoPath Forms Services are loaded, as necessary, into the single Application Domain that SharePoint uses and controls. When the Application Domain is recycled, business logic assemblies are not reloaded until they are requested again.

Business logic assemblies are stored on each front-end Web server and loaded by InfoPath Forms Services using the LoadFrom method of the Assembly.NET Framework class, which includes semantics to merge the input evidence with the evidence collected by the loader to create a final set of evidence used for policy resolution.

Notes About Using and Referencing Assemblies

  • If you need to share assemblies among multiple form templates, put the shared assemblies into each form template. Be aware, however, that if a second or subsequent form template uses the same assembly but is marked with a higher or lower security level, the shared assembly will inherit the corresponding Application Domain permission set of the first form template's security level.

  • A form that contains custom business logic assemblies will fail conversion if any of the form assemblies have the same identity as an assembly in a form that has already been converted and the assemblies do not compare bitwise.