首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

自动更新出现win32Exception解决办法

2012-06-15 
自动更新出现win32Exception我在做一个客户端自动更新程序,版本比对侯到更新程序单独做的更新和下载出现wi

自动更新出现win32Exception
我在做一个客户端自动更新程序,版本比对侯到更新程序
单独做的更新和下载出现win32Exception 异常
代码片段大家帮忙看下是什么问题
private void endPost(object o, EventArgs e)
  {
  byte[] resultstr = (byte[])o;

  if (resultstr != null)
  {
  Msg msg = Serializer.Deserialize<Msg>(OptBase.byte2stream(resultstr));
  int serviceVersion = msg.version; //服务器版本
  int minorVersion = GetSerial.getMinorVersion(); //当前版本版本
  if (serviceVersion > minorVersion)
  {
  try
  {
  MessageBox.Show("检测到有新版本发布了,是否需要更新!", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button3);
  System.Diagnostics.Process.Start("update.exe", GlobParams.baseURL); //执行这出现异常
  Application.Exit(); 
  }
  catch(Exception ex)
  {
  throw new Exception("升级失败了,原因是:" + ex.Message,ex);
  }
  }
  else
  {
  //当前版本小于服务端版本
  Status ld = new Status();
  ld.ShowDialog();
  ld.Dispose();
  }
  }
  else 
  {
  Status ld = new Status();
  ld.ShowDialog();
  ld.Dispose();
  }
  }

//update.exe代码片段
private string baseURL = "";
  public Form1()
  {
  InitializeComponent();
  baseURL = System.Environment.GetCommandLineArgs().GetValue(1).ToString();
  }


[解决办法]
Exception 的 Message是什么?

有没有InnerException,它的MEssage是什么。
[解决办法]
GlobParams.baseURL这个是什么?

我的做法和你类似,从未出问题,

C# code
            double NewVer = Convert.ToDouble(new BLL.SYS_UpdateManager().GetNewVer());            double CurrVer = Convert.ToDouble(allensingleton.currentlyVersion);            if (NewVer > CurrVer)            {                DialogResult dr = MessageBox.Show("发现新的版本是否要更新该软件?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);                if (dr == DialogResult.OK)                {                    Process.Start(@"C:\Program Files\CMS\MesUpdate.exe");                    this.Dispose();                    this.Close();                }            }
[解决办法]
Console.WriteLine(ex.ToString());

会把InnerException的内容也打印出来。

热点排行