How to: Create file associations for a ClickOnce application
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. 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
Create a ClickOnce application normally, or use your existing ClickOnce application.
Open the application manifest with a text or XML editor, such as Notepad.
Find the
assembly
element. For more information, see ClickOnce application manifest.As a child of the
assembly
element, add afileAssociation
element. ThefileAssociation
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
andfileAssociation
elements, see <fileAssociation> Element.
If you want to associate more than one file type with the application, add additional
fileAssociation
elements. Note that theprogid
attribute should be different for each.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).