Share via


How to: Log and Reset InfoPath Forms Services Configuration Settings

Applies to: SharePoint Server 2010

For the purposes of this task, the FormsService class and associated members are used to set the default values for most of the items on the Configure InfoPath Forms Services page, which is available on the General Application Settings page of the SharePoint 2010 Central Administration site.

The form that you create for this project contains a button and a rich text box. When executed, the rich text box is populated with the name of the class member used to set a configuration property, and the old and new values of each member.

Note

This topic assumes that Microsoft Visual Studio is installed on the Web front-end (WFE) or single farm server that is running InfoPath Forms Services.

To set up the project

  1. Create a new Visual Basic Windows Forms Application project in Microsoft Visual Studio.

  2. On the Project menu, click Add Reference.

  3. On the .NET tab of the Add Reference dialog box, select Microsoft SharePoint Foundation, and then click OK. (If Microsoft SharePoint Foundation is not available on the .NET tab, on the Browse tab, browse to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\, select the Microsoft.SharePoint.dll assembly, and then click OK.

  4. On the Project menu, click Add Reference again.

  5. On the Browse tab of the Add Reference dialog box, browse to C:\Program Files\Microsoft Office Servers\14.0\Bin\, select the Microsoft.Office.InfoPath.Server.dll assembly, and then click OK.

To add controls and code to the form

  1. Add the following controls to the form. These can be found in the All Windows Forms category of the Visual Studio Toolbox:

    • A Button control

    • A RichTextBox control

  2. Rename the button to "List and Reset Configuration Settings" by modifying the Text property of the button in the Properties Window.

  3. Reposition and resize the form and the controls until all text can be seen on the button and the RichTextBox control fills most of the form.

  4. On the View menu, click Code.

  5. Paste the following code into the code window, replacing all existing code.

  6. Click Form1.vb [Design] on the Window menu.

  7. In the Properties Window, click the drop-down list, and then select Button1.

  8. In the Properties Window, click the Events button, which is typically the fourth button from the left in the row of buttons under the drop-down list.

  9. In the Action section, click the drop-down for the Click event, and then select Button1_Click.

  10. On the File menu, click Save All.

  11. Press F5 to run the application.

Example

Use the procedures earlier in this section to create a new Visual Basic Windows Forms application that uses the following code example to log and reset InfoPath Forms Services configuration settings.

Imports Microsoft.SharePoint.Administration
Imports Microsoft.Office.InfoPath.Server.Administration

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim LocalFormsService As FormsService
        Dim LocalFarm As SPFarm = SPFarm.Local
        Dim StrLog As String = ""

        Try
            LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
            'Build a string with the old a new value of each property
            With LocalFormsService
                StrLog = StrLog + "ActiveSessionsTimeout changed from " + _
                .ActiveSessionsTimeout.ToString() + " to 1440." + Environment.NewLine
                .ActiveSessionsTimeout = 1440

                StrLog = StrLog + "AllowEmbeddedSqlForDataConnections changed from " + _
                .AllowEmbeddedSqlForDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowEmbeddedSqlForDataConnections = False

                StrLog = StrLog + "AllowUdcAuthenticationForDataConnections changed from " + _
                .AllowUdcAuthenticationForDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowUdcAuthenticationForDataConnections = False

                StrLog = StrLog + "AllowUserFormBrowserEnabling changed from " + _
                .AllowUserFormBrowserEnabling.ToString() + " to True." + Environment.NewLine
                .AllowUserFormBrowserEnabling = True

                StrLog = StrLog + "AllowUserFormBrowserRendering changed from " + _
                .AllowUserFormBrowserRendering.ToString() + " to True." + Environment.NewLine
                .AllowUserFormBrowserRendering = True

                StrLog = StrLog + "AllowUserFormCrossDomainDataConnections changed from " + _
                .AllowUserFormCrossDomainDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowUserFormCrossDomainDataConnections = False

                StrLog = StrLog + "AllowViewState changed from " + _
                .AllowViewState.ToString() + " to False." + Environment.NewLine
                .AllowViewState = False

                StrLog = StrLog + "DefaultDataConnectionTimeout changed from " + _
                .DefaultDataConnectionTimeout.ToString() + " to 10000." + Environment.NewLine
                .DefaultDataConnectionTimeout = 10000

                StrLog = StrLog + "MaxDataConnectionResponseSize changed from " + _
                .MaxDataConnectionResponseSize.ToString() + " to 1500." + Environment.NewLine
                .MaxDataConnectionResponseSize = 1500

                StrLog = StrLog + "MaxDataConnectionTimeout changed from " + _
                .MaxDataConnectionTimeout.ToString() + " to 20000." + Environment.NewLine
                .MaxDataConnectionTimeout = 20000

                StrLog = StrLog + "MaxPostbacksPerSession changed from " + _
                .MaxPostbacksPerSession.ToString() + " to 75." + Environment.NewLine
                .MaxPostbacksPerSession = 75

                StrLog = StrLog + "MaxSizeOfFormSessionState changed from " + _
                .MaxSizeOfFormSessionState.ToString() + " to 4194304." + Environment.NewLine
                .MaxSizeOfFormSessionState = 4194304

                StrLog = StrLog + "MaxUserActionsPerPostback changed from " + _
                .MaxUserActionsPerPostback.ToString() + " to 200." + Environment.NewLine
                .MaxUserActionsPerPostback = 200

                StrLog = StrLog + "RequireSslForDataConnections changed from " + _
                .RequireSslForDataConnections.ToString() + " to False." + Environment.NewLine
                .RequireSslForDataConnections = False

                StrLog = StrLog + "ViewStateThreshold changed from " + _
                .ViewStateThreshold.ToString() + " to 40960." + Environment.NewLine
                .ViewStateThreshold = 40960
            End With
            'Populate the rich text box with the log
            RichTextBox1.Text = StrLog
        Catch ex As Exception
            MessageBox.Show("An error has occurred: " + ex.Message.ToString())
        End Try

    End Sub
End Class

See Also

Other Resources

Developing Windows Applications to Perform InfoPath Forms Services Administration Tasks