C#获取安装的更新

我正在尝试使用此功能安装更新。 在某些机器上工作正常,但在其他机器上崩溃了,但我没有收到任何错误 甚至“开始”文本也不会显示在文件中。 我正在Windows 7 64x中测试此应用程序。

   public void UpdateIsInstall(StreamWriter output)
    {
        output.WriteLine("Start");
        UpdateSession uSession = new UpdateSession();
        IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
        uSearcher.Online = false;
        try
        {
            ISearchResult sResult = uSearcher.Search("IsInstalled=1 And IsHidden=0");
            foreach (IUpdate update in sResult.Updates)
            {
                String hotfixes = ExtractString(update.Title + Environment.NewLine) + "";

                output.WriteLine("{");
                output.WriteLine("\"Correctif\": \"" + hotfixes.Replace(@"""", "\"") + "\",");
                output.WriteLine("\"InstallOn\": \"" + update.LastDeploymentChangeTime.Date.ToShortDateString() + "\"");
                output.WriteLine("},");

            }
        }
        catch (Exception ex)
        {
            output.Write(ex.ToString());
        }

    }