Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication.Restart not passing arguments back
    primarykey
    data
    text
    <p>This is a ClickOnce application. According to the <a href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k%28SYSTEM.WINDOWS.FORMS.APPLICATION.RESTART%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK,VERSION=V4.0%22%29;k%28DevLang-CSHARP%29&amp;rd=true" rel="noreferrer">documentation</a>, "<em>If your application was originally supplied command-line options when it first executed, Restart will launch the application again with the same options.</em>". But I don't know if this is supposed to work or not with ClickOnce applications. If so, what am I doing wrong?</p> <p>Here is my code:</p> <pre><code>public Form1() { InitializeComponent(); textBox1.Text = string.Join(Environment.NewLine, GetCommandLineFile()); } private static string[] GetCommandLineFile() { if (AppDomain.CurrentDomain != null &amp;&amp; AppDomain.CurrentDomain.SetupInformation != null &amp;&amp; AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &amp;&amp; AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &amp;&amp; AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Any()) { return AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData; } else return new string[] { }; } private void button1_Click(object sender, EventArgs e) { Application.Restart(); } </code></pre> <p>I associated my application with the <code>.abc</code> extension and when I double click my <code>.abc</code> file, the application will launch with the file name as the only argument, but then when I restart (by pressing my <code>button1</code>), <code>GetCommandLineFile()</code> will return an empty array.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload