卸载有问题吗? [英] Uninstall Problem?

查看:65
本文介绍了卸载有问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

以下是我的卸载代码.

Hi All,

Below is my code for uninstallation.

private void Uninstall()
       {
           try
           {
               string[] arguments = Environment.GetCommandLineArgs();
               foreach (string argument in arguments)
               {
                   if (argument.Split('=')[0].ToLower() == "/u")
                   {
                       string guid = argument.Split('=')[1];
                       string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
                       ProcessStartInfo si = new ProcessStartInfo(path + "/msiexec.exe", "/x " + guid);
                       Process.Start(si);
                       Close();
                       Application.Exit();
                   }
               }
           }
           catch (Exception ex)
           {
               DataClass.LogError(ex);
           }
       }



当我要卸载应用程序时
我得到Visual Studio时不发送错误消息.

DSIL遇到问题,需要关闭.不便之处,敬请原谅.

如果您在某个地方,您正在处理的信息可能会丢失.
调试SendError报告不发送

该如何解决?
让我知道你是否有主意.

预先感谢,
Pawan.



When i am going to uninstall the application
i am getting Visual studio don''t send Error message.

DSIL has encountered a problem and needs to close. We are sorry for the inconvenience.

if u were in the middle of something, the information you were working on might be lost.
Debug SendError Report Don''t Send

How to resolve this?
do let me know if u have an idea.

Advance Thanks,
Pawan.

推荐答案

您描述的错误,我相信是由于您的应用程序早日返回所致.

卸载时,建议等待该过程完成其执行.
您提供的示例关闭,退出应用程序线程,这当然会使卸载过程无效.
尝试使用
The error you described, i believe that its due to early return of your application.

While uninstalling it is advisable to wait for the process to complete its execution.
The example you have given, closes and exits the application thread, which of course invalidates the uninstall process.
Try using
ProcessStartInfo startInfo = new ProcessStartInfo(
    "cmd.exe",
    string.Format("/c start /MIN /wait msiexec.exe /x {0} /quiet", guid));
startInfo.WindowStyle = ProcessWindowStyle.Hidden;

Process process = Process.Start(startInfo);
process.WaitForExit();


只需放置System.Environment.Exit(0);在Application.Exit()之后;它工作正常,没有不发送错误".

private void Uninstall()
{
试试
{
字符串[]参数= Environment.GetCommandLineArgs();
foreach(参数中的字符串参数)
{
如果(argument.Split(''='')[0] .ToLower()=="/u")
{
字符串guid = arguments.Split(''='')[1];
字符串路径= Environment.GetFolderPath(Environment.SpecialFolder.System);
ProcessStartInfo si =新的ProcessStartInfo(path +"/msiexec.exe","/i" + guid);
Process.Start(si);
Close();
Application.Exit();

System.Environment.Exit(0);



}
}
}
catch(ex ex例外)
{
DataClass.LogError(ex);
}
}
just place the System.Environment.Exit(0); after Application.Exit(); it works fine and no Don''t Send error.

private void Uninstall()
{
try
{
string[] arguments = Environment.GetCommandLineArgs();
foreach (string argument in arguments)
{
if (argument.Split(''='')[0].ToLower() == "/u")
{
string guid = argument.Split(''='')[1];
string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
ProcessStartInfo si = new ProcessStartInfo(path + "/msiexec.exe", "/i " + guid);
Process.Start(si);
Close();
Application.Exit();

System.Environment.Exit(0);



}
}
}
catch (Exception ex)
{
DataClass.LogError(ex);
}
}


这篇关于卸载有问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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