Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6622641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:25:59+00:00 2026-05-25T21:25:59+00:00

I have a VB.NET application that takes command-line arguments. It works fine when debugging

  • 0

I have a VB.NET application that takes command-line arguments.

It works fine when debugging provided I turn off Visual Studio’s ClickOnce security setting.

The problem occurs when I try to install the application on a computer via ClickOnce and try to run it with arguments. I get a crash when that happens (oh noes!).

There is a workaround for this issue: move the files from the latest version’s publish folder to a computer’s C: drive and remove the “.deploy” from the .exe. Run the application from the C: drive and it will handle arguments just fine.

Is there a better way to get this to work than the workaround I have above?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:26:00+00:00Added an answer on May 25, 2026 at 9:26 pm

    “Command-line arguments” only work with a ClickOnce app when it is run from a URL.

    For example, this is how you should launch your application in order to attach some run-time arguments:

    http://myserver/install/MyApplication.application?argument1=value1&argument2=value2

    I have the following C# code that I use to parse ClickOnce activation URL’s and command-line arguments alike:

    public static string[] GetArguments()
    {
        var commandLineArgs = new List<string>();
        string startupUrl = String.Empty;
    
        if (ApplicationDeployment.IsNetworkDeployed &&
            ApplicationDeployment.CurrentDeployment.ActivationUri != null)
        {
            // Add the EXE name at the front
            commandLineArgs.Add(Environment.GetCommandLineArgs()[0]);
    
            // Get the query portion of the URI, also decode out any escaped sequences
            startupUrl = ApplicationDeployment.CurrentDeployment.ActivationUri.ToString();
            var query = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
            if (!string.IsNullOrEmpty(query) && query.StartsWith("?"))
            {
                // Split by the ampersands, a append a "-" for use with splitting functions
                string[] arguments = query.Substring(1).Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Select(a => String.Format("-{0}", HttpUtility.UrlDecode(a))).ToArray();
    
                // Now add the parsed argument components
                commandLineArgs.AddRange(arguments);
            }
        }
        else
        {
            commandLineArgs = Environment.GetCommandLineArgs().ToList();
        }
    
        // Also tack on any activation args at the back
        var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
        if (activationArgs != null && activationArgs.ActivationData.EmptyIfNull().Any())
        {
            commandLineArgs.AddRange(activationArgs.ActivationData.Where(d => d != startupUrl).Select((s, i) => String.Format("-in{1}:\"{0}\"", s, i == 0 ? String.Empty : i.ToString())));
        }
    
        return commandLineArgs.ToArray();
    }
    

    Such that my main function looks like:

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            var commandLine = GetArguments();
            var args = commandLine.ParseArgs();
    
            // Run app
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web application that takes user input across several forms. Sort
I have an ASP.Net application that takes an unusually long time to start up
I have a WCF application, written in VB.NET that takes a generic Dictionary(Of String,
I have a very weird problem. I have a VB.NET 2.0 application that takes
I have problems with step-by-step debugging of a multithreaded .NET application in Visual Studio
I have a .Net web application that I want to take a copy of
I have a .NET application that is meant to be run on a local
I have a .NET application that processes around 300,000 records in a batch import,
I have a .NET application that I want to use as a client to
We have a .net application that we didn't develop, but use. I can tell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.