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

StackOverflow https://stackoverflow.com/questions/20518112

  •  31-08-2022
  •  | 
  •  

Question

I have a .NET application that is published using ClickOnce. For the most part, everything works well with this procedure, but every once in a while, a user will get an error that throws up the message shown below instead of opening the program:

Application cannot be started. Contact the application vendor.

enter image description here

I found the Troubleshooting Specific Errors in ClickOnce Deployments page on MSDN which states (in the Additional Errors section):

Error message

Application cannot be started. Contact the application publisher.

Cannot start the application. Contact the application vendor for assistance.

Description

These are generic error messages that occur when the application cannot be started, and no other specific reason can be found. Frequently this means that the application is somehow corrupted, or that the ClickOnce store is corrupted.

While it's not an exact match for the error message that is displayed for this problem, I think that it is close enough to fit into the above category of errors. Now the fix for this problem is to simply delete all of the ClickOnce user settings that are stored in...

C:\Users\USERNAME\AppData\Local\Apps\2.0  

... so the problem is bearable, but my question is this:

What can I do to find out what is causing these generic errors so that I can stop them from occurring?

Was it helpful?

Solution

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.

OTHER TIPS

If your project is 64 bit and you try to copy it to \windows\system32, you get this error. Moving the .exe to \windows\syswow64 fixes the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top