I have a ClickOnce application with file associations and am having issues with the args

695 views Asked by At

Here is my Program Main:

static void Main(string[] args)
    {
        for (int r = 0; r <= args.Length ; r++ )
        {
            MessageBox.Show(args[r]);
        }
        if (args != null && args.Length > 0)
        {
            string filename = args[0];

            if (File.Exists(filename))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Location_Alert MainForm = new Location_Alert();
                MainForm.ImportFile(filename);
                Application.Run(MainForm);
            }
        }
        else
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Location_Alert());
        }

the problem is, when I launch the *.enot file that is associated with the program, the program launches, but the arguments don't seem to be setting, as args is empty.

Is there some trick to this specific to ClickOnce that I am missing?

1

There are 1 answers

0
Jacrys On BEST ANSWER

Found on ClickOnce File Association:

The problem stemmed for 1 not necessarily understanding ClickOnce, thanks codeConcussion for the brief overview.

And 2, that ClickOnce does not pass things through the traditional args format but through the following property: AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData