views:

88

answers:

2

I want to associate a file extension with my ClickOnce application. There is a File Associations part in the Publish options but I can't manage to make it work.

+1  A: 

In order to use file associations, your project must conform to a few rules...

  • Full Trust is required.
  • Must be available "offline".
  • Must target 3.5 Framework.

If you are already doing all these things, what, exactly, isn't working?

whatknott
In the *File Associations* part, I fill the different parameters (Extention, Description and ProgID) and choose an icon, but when deploying the application, no association is made between the file extension and my program.
tinmaru
A: 

Have you added the code inside the application to handle the file name passed in when the user double-clicks on it and do something with it? You need something like this in your startup.

string fileName = string.Empty;
string[] activationData = 
  AppDomain.CurretnDomain.SetupInformation.ActivationArguments.ActivationData;
if (activationData != null && activationData.Length > 0)
{
    Uri uri = new Uri(activationdata[0]);
    fileName = url.LocalPath.ToString();
}

Then you have to add code to do something with the file.

RobinDotNet