XsnFeatureReceiver XsnFeatureReceiver XsnFeatureReceiver Class

Definition

Based on the SPFeatureReceiver class and used to trap the activation, deactivation, installation, or uninstallation of a SharePoint feature containing an InfoPath form template.

public ref class XsnFeatureReceiver : Microsoft::SharePoint::SPFeatureReceiver
public class XsnFeatureReceiver : Microsoft.SharePoint.SPFeatureReceiver
Public Class XsnFeatureReceiver
Inherits SPFeatureReceiver
Inheritance
XsnFeatureReceiverXsnFeatureReceiverXsnFeatureReceiver

Examples

<p>In the following example, a Windows class library is used to receive SharePoint feature events. The assembly must be signed and deployed to the Global Assembly Cache (GAC), much like other custom SharePoint assemblies.</p>
<p>[C#]</p>
<pre><code>using System;

using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; using Microsoft.Office.InfoPath.Server.Administration;

namespace Freceive { public class ReceivedXSN : <span class="label">XsnFeatureReceiver</span> { public override void FeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties properties) { FeatureActivated(properties); SPFeatureDefinition xsnDefinition = properties.Feature.Definition; Guid xsnID = properties.Feature.DefinitionId; Console.WriteLine("Freceive: Feature Definition is " + xsnDefinition); Console.WriteLine("Freceive: Feature ID is " + xsnID); Console.WriteLine("Press any key to continue"); Console.ReadLine(); } public override void FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties properties) { base.FeatureDeactivating(properties); Console.WriteLine("Freceive: Deactivated"); Console.WriteLine("Press any key to continue"); Console.ReadLine(); } public override void FeatureInstalled(Microsoft.SharePoint.SPFeatureReceiverProperties properties) { Console.WriteLine("Freceive: Installed"); Console.WriteLine("Press any key to continue"); Console.ReadLine(); } public override void FeatureUninstalling(Microsoft.SharePoint.SPFeatureReceiverProperties properties) { base.FeatureUninstalling(properties); Console.WriteLine("Freceive: Uninstalling"); Console.WriteLine("Press any key to continue"); Console.ReadLine(); }

Remarks

Use the XsnFeatureReceiver class to trap events that are raised after an InfoPath form template installation, uninstallation, activation, or deactivation on the server. The assembly and class name used to trap these events must be referenced in the feature.xml file used to deploy the SharePoint feature containing one or more InfoPath form templates.

Note: It is not possible to cancel installation or uninstallation through feature events.

Using the XsnFeatureReceiver Class

You can use the XsnFeatureReceiver class by directly referencing the class in your feature definition. For example, a form template named Example.xsn is located in a custom feature folder along with the Feature.xml and Elements.xml file. The custom feature folder is located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES. The feature is deployed using the command line "stsadm -o installfeature -filename FeatureFolderName\feature.xml". The feature is then activated to a SharePoint site with the command line "stsadm -o activatefeature –filename FeatureFolderName\Feature.xml -url http://ServerName/".

Important: The FeatureFolderName, ServerName, Feature Id, and File Name are placeholder values. Substitute values that pertain to your environment.

Feature.xml

&lt;?xml version="1.0" encoding="us-ascii" standalone="yes"?&gt;
&lt;Feature Id="2CCB7482-69D4-4084-AEC2-A867C91FEF88" 
    Title="Simple Form Template" 
    Description="This is simple form template" 
    Version="1.0.0.0" 
    Scope="Site" 
    ReceiverClass="Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver" 
    ReceiverAssembly="Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 
    xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    &lt;ElementManifests&gt;
        &lt;ElementManifest Location="Elements.xml" /&gt;
        &lt;ElementFile Location="Example.xsn" /&gt;
    &lt;/ElementManifests&gt;
    &lt;ActivationDependencies&gt;
        &lt;ActivationDependency FeatureId="C88C4FF1-DBF5-4649-AD9F-C6C426EBCBF5" /&gt;
    &lt;/ActivationDependencies&gt;
&lt;/Feature&gt;

Elements.xml

&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    &lt;Module Name="XSN" Url="FormServerTemplates" RootWebOnly="TRUE"&gt;
        &lt;File Url="Example.xsn" Name="Example.xsn" Type="GhostableInLibrary" /&gt;
    &lt;/Module&gt;
&lt;/Elements&gt;

Extending the XsnFeatureReceiver Class

If you wish to extend the XsnFeatureReceiver class using code similar to the example below, the following example Feature.xml and Elements.xml files are required to deploy the feature with the command line "stsadm -o installfeature -filename FeatureFolderName\feature.xml". The feature is then activated to a SharePoint site with the command line "stsadm -o activatefeature –filename FeatureFolderName\Feature.xml -url http://ServerName/Sitecollection".

Important: The FeatureFolderName, ServerName, Sitecollection, Feature Id, ReceiverAssembly, ReceiverClass, and File Name are placeholder values. Substitute the values that pertain to your environment and custom XsnFeatureReceiver class.

Feature.xml

&lt;?xml version="1.0"?&gt;
&lt;Feature Id="E57DD3BD-C295-4f9d-A2F1-BB791257CCDC" Title="My Custom Page"
    Description="This feature adds an aspx page with a hosted
XmlFormView control" Version="1.0.0.0" Scope="Web"
    ReceiverAssembly="Freceive, Version=1.0.0.0, Culture=neutral, PublicKeyToken=50b6d1f1666192d2"
    ReceiverClass="Freceive.ReceivedXSN"
    xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
&lt;ElementManifests&gt;
    &lt;ElementManifest Location="Elements.xml"/&gt;
&lt;/ElementManifests&gt;
&lt;/Feature&gt;

Elements.xml

&lt;?xml version="1.0"?&gt;
&lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    &lt;Module&gt;
        &lt;File Name="MyCustomPage.aspx" Type="GhostableInLibrary"/&gt;
    &lt;/Module&gt;
&lt;/Elements&gt;

Constructors

XsnFeatureReceiver() XsnFeatureReceiver() XsnFeatureReceiver()

Initializes a new instance of the XsnFeatureReceiver class.

Methods

FeatureActivated(SPFeatureReceiverProperties) FeatureActivated(SPFeatureReceiverProperties) FeatureActivated(SPFeatureReceiverProperties)

Occurs after a SharePoint feature containing an InfoPath form template is activated.

FeatureDeactivating(SPFeatureReceiverProperties) FeatureDeactivating(SPFeatureReceiverProperties) FeatureDeactivating(SPFeatureReceiverProperties)

Occurs when a SharePoint feature is deactivated.

FeatureInstalled(SPFeatureReceiverProperties) FeatureInstalled(SPFeatureReceiverProperties) FeatureInstalled(SPFeatureReceiverProperties)

Occurs after a SharePoint feature is installed.

FeatureUninstalling(SPFeatureReceiverProperties) FeatureUninstalling(SPFeatureReceiverProperties) FeatureUninstalling(SPFeatureReceiverProperties)

Occurs when a SharePoint feature is uninstalling.

FeatureUpgrading(SPFeatureReceiverProperties, String, IDictionary<String,String>) FeatureUpgrading(SPFeatureReceiverProperties, String, IDictionary<String,String>) FeatureUpgrading(SPFeatureReceiverProperties, String, IDictionary<String,String>) Inherited from SPFeatureReceiver

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to