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

故事扮演 提交于 2019-11-29 09:13:16

问题


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.

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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/20518112/how-to-find-out-what-causes-the-generic-application-cannot-be-started-contact

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!