Compartilhar via


How to: Create File Associations For a ClickOnce Application

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

ClickOnce applications can be associated with one or more file name extensions, so that the application will be started automatically when the user opens a file of those types. Adding file name extension support to a ClickOnce application is straightforward.

To create file associations for a ClickOnce application

  1. Create a ClickOnce application normally, or use your existing ClickOnce application.

  2. Open the application manifest with a text or XML editor, such as Notepad.

  3. Find the assembly element. For more information, see ClickOnce Application Manifest.

  4. As a child of the assembly element, add a fileAssociation element. The fileAssociation element has four attributes:

    • extension: The file name extension you want to associate with the application.

    • description: A description of the file type, which will appear in the Windows shell.

    • progid: A string uniquely identifying the file type, to mark it in the registry.

    • defaultIcon: An icon to use for this file type. The icon must be added as a file resource in the application manifest. For more information, see How to: Include a Data File in a ClickOnce Application.

      For an example of the file and fileAssociation elements, see <fileAssociation> Element.

  5. If you want to associate more than one file type with the application, add additional fileAssociation elements. Note that the progid attribute should be different for each.

  6. Once you have finished with the application manifest, re-sign the manifest. You can do this from the command line by using Mage.exe.

    mage -Sign WindowsFormsApp1.exe.manifest -CertFile mycert.pfx

    For more information, see Mage.exe (Manifest Generation and Editing Tool)

See Also

<fileAssociation> Element
ClickOnce Application Manifest
Mage.exe (Manifest Generation and Editing Tool)