Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Below is my code for uninstallation.
C#
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);
           }
       }


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

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
C#
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();
 
Share this answer
 
v2
Comments
Pawan Kiran 28-Sep-10 8:05am    
Dear GpuToaster,

still i am getting Visual studio don't send Error message.

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("cmd.exe", string.Format("/c start /MIN /wait msiexec.exe /x {0} /quiet", guid));
si.WindowStyle = ProcessWindowStyle.Hidden;
Process process=Process.Start(si);
process.WaitForExit();
//Close();
//Application.Exit();
}
}
}
catch (Exception ex)
{
DataClass.LogError(ex);
}
}

Please Let me know if u have an answer.
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);
}
}
 
Share this answer
 
Comments
Estys 4-Jan-11 7:04am    
Why revive an age-old posting?
The OP has probably died long ago of old age.
Beside that you should decorate the code snippet in pre tags
Pawan Kiran 5-Jan-11 4:31am    
Thank u very much Mr.Deepak
it solves my problem..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900