<fileAssociation> Element (ClickOnce Application)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at <fileAssociation> Element (ClickOnce Application).

Identifies a file extension to be associated with the application.

<fileAssociation  
    xmlns="urn:schemas-microsoft-com:clickonce.v1"  
    extension  
    description  
    progid  
    defaultIcon  
/>  

The fileAssociation element is optional. The element has the following attributes.

AttributeDescription
extensionRequired. The file extension to be associated with the application.
descriptionRequired. A description of the file type for use by the shell.
progidRequired. A name uniquely identifying the file type.
defaultIconRequired. Specifies the icon to use for files with this extension. The icon file must be specified by using the <file> Element within the <assembly> Element that contains this element.

This element must include an XML namespace reference to "urn:schemas-microsoft-com:clickonce.v1". If the <fileAssociation> element is used, it must come after the <application> element in its parent <assembly> Element.

ClickOnce will not overwrite existing file associations. However, a ClickOnce application can override the file extension for the current user only. After that ClickOnce application is uninstalled, ClickOnce deletes the file association for the user, and the per-machine association is active again.

The following code example illustrates fileAssociation elements in an application manifest for a text editor application deployed using ClickOnce. This code example also includes the <file> Element required by the defaultIcon attribute.

<file name="text.ico" size="4286">  
  <hash>  
    <dsig:Transforms>  
      <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />  
    </dsig:Transforms>  
    <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />  
    <dsig:DigestValue>0joAqhmfeBb93ZneZv/oTMP2brY=</dsig:DigestValue>  
  </hash>  
</file>  
<file name="writing.ico" size="9662">  
  <hash>  
    <dsig:Transforms>  
      <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />  
    </dsig:Transforms>  
    <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />  
    <dsig:DigestValue>2cL2U7cm13nG40v9MQdxYKazIwI=</dsig:DigestValue>  
  </hash>  
</file>  
<fileAssociation xmlns="urn:schemas-microsoft-com:clickonce.v1" extension=".text" description="Text  Document (ClickOnce)" progid="Text.Document" defaultIcon="text.ico" />  
<fileAssociation xmlns="urn:schemas-microsoft-com:clickonce.v1" extension=".writing" description="Writings (ClickOnce)" progid="Writing.Document" defaultIcon="writing.ico" />  

ClickOnce Application Manifest

Show: