如何找出导致通用“应用程序无法启动的原因”。与应用程序供应商联系。 ClickOnce错误? [英] How to find out what causes the generic 'Application cannot be started. Contact the application vendor.' ClickOnce errors?

查看:244
本文介绍了如何找出导致通用“应用程序无法启动的原因”。与应用程序供应商联系。 ClickOnce错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ClickOnce发布的.NET应用程序。在大多数情况下,此过程都可以正常运行,但是偶尔,用户会收到一条错误消息,抛出以下消息,而不是打开程序:

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.

我发现对MSDN上的ClickOnce部署中的特定错误进行故障排除页,该页指出(在其他错误部分中):

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.

这些是一般错误消息,它们在无法启动应用程序且没有其他特定原因可以启动时发生被发现。通常,这意味着应用程序某种程度上已损坏,或者ClickOnce存储已损坏。

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.

虽然与显示的错误消息不完全匹配对于这个问题,我认为它足够接近上述错误类别。现在,解决此问题的方法是简单地删除存储在...中的所有ClickOnce用户设置。

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:

我该怎么做才能找出导致这些一般性错误的原因,从而阻止它们的发生?

推荐答案

2件事:


  1. 如果单击详细信息...按钮,您将获得一个日志文件,该文件通常显示错误的内容(可能是服务器上的清单文件损坏等)。

  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).

如果您说删除本地设置帮助,则可能是user.config文件损坏了。我们的应用程序中出现了这个问题-我无法找出原因(我的猜测是我经常写给 Properties.Settings ,但我不确定)。无论如何,这是我的解决方法:

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.

这篇关于如何找出导致通用“应用程序无法启动的原因”。与应用程序供应商联系。 ClickOnce错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆