2

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?

Jacrys
  • 692
  • 1
  • 7
  • 20
  • I don't really get the question I think... Do you pass args when running this program? Iff so, you are giving this program a list of filenames, these args do not show up in the messagebox? If this is the main program, so the first instance of this application, I am not sure where you think the array (args) should come from... – CularBytes Nov 13 '14 at 21:04
  • As stated in the explanation below the code block, I have an *.enot associated with the application. when double clicking on this file, ags should be passed to the called program by Windows. These args are in an array of strings. Instead, however, my program reports that the array is empty. From my understanding of file associations and the run program behaviour, the full file path of the file that was launched to pass through to the associated program as args. – Jacrys Nov 13 '14 at 21:17
  • strange, as it does run your application, I assume it is associated fine (or did you manually choose what program to execute it?) I wish I could help you further but I'm not that experienced yet with file association, I found this video pretty well explained, it might help: https://www.youtube.com/watch?v=XtYobuVvcFE – CularBytes Nov 13 '14 at 21:53
  • It associated fine, I used ClickOnce's association to do this, and it does open the program, but without the pass-through operating correctly, it does not import the file. – Jacrys Nov 14 '14 at 06:22

1 Answers1

4

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

Community
  • 1
  • 1
Jacrys
  • 692
  • 1
  • 7
  • 20