How to find out what causes the generic 'Application cannot be started. Contact the application vendor.' ClickOnce errors?

2 things:

  1. If you click that "Details..." button you will get a log file which, usually, shows what the error is (it could be broken manifest file on server, etc).

  2. If you say deleting local settings help, then it might be that user.config file gets corrupted. We had this issue in our app - and I was not able to find out WHY (my guess was that I was writing to Properties.Settings too often but I'm not sure). Anyway, here is my workaround for it:

    public static void Main()
    {
        if (ApplicationDeployment.IsNetworkDeployed == true)
        {
            try
            {
                 ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
            }
            catch (ConfigurationErrorsException ex)
            {
                string filename = ex.Filename;
                _logger.Error(ex, "Cannot open config file");
    
                if (File.Exists(filename) == true)
                {
                    _logger.Error("Config file {0} content:\n{1}", filename, File.ReadAllText(filename));
                    File.Delete(filename);
                    _logger.Error("Config file deleted");
                    Properties.Settings.Default.Upgrade();
                    // Properties.Settings.Default.Reload();
                    // you could optionally restart the app instead
                }
                else
                {
                    _logger.Error("Config file {0} does not exist", filename);
                }
            }
        }
        // code continues...
    }
    

    basically I try to read settings, if any error - log the broken file's content, delete it and continue.

Tags:

.Net

Clickonce