Click here to Skip to main content
13,798,425 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
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);
           }
       }


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 28-Sep-10 1:57am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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();
  Permalink  
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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);
}
}
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181207.3 | Last Updated 4 Jan 2011
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100