Application.RegisterFormTemplate method (String, String)

Office 2013 and later

Installs the specified form template with the option to overwrite the previous registration record for the form template.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract void RegisterFormTemplate(
	string formTemplateLocation,
	string behavior


Type: System.String

Specifies the Uniform Resource Locator (URL) of the form template. This parameter can be specified as a form definition (.xsf) file or a form template (.xsn) file.

Type: System.String

Specifies how the form template is to be installed. The default value is "overwrite". The only other valid value for this parameter is "new-only".


The form template file cannot be found.


The parameters passed to this method are a null reference (Nothing in Visual Basic).


The parameters passed to this method are not valid. For example, they are of the wrong type or format.

If the form template has already been registered, and "new-only" is specified for the behavior parameter, the RegisterFormTemplate method will return an error. If "overwrite" is specified, the form template's registration record will be overwritten.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

In the following example, the RegisterFormTemplate method of the Application class is used in a function to install a form template. The example assumes that there is a using or Imports statement for the Microsoft.Office.InfoPath namespace in the declarations section of the class that contains the function, and that the Microsoft InfoPath 3.0 Type Library is referenced on the COM tab of the Add Reference dialog box in Visual Studio.

public void InstallForm()
Microsoft.Office.InfoPath.Application infoPathApp = 
   new Microsoft.Office.InfoPath.Application();
infoPathApp.RegisterFormTemplate(@"C:\My Forms\MyFormTemplate.xsn",