none
拜託救救我~應用程式驗證失敗 RRS feed

  • 問題

  •  

    我做了一個應用程式exe檔來呼叫webServices,原本執行的時候可以執行。當初設成10秒和5分鐘執行都可以,當我改成3小時執行時就發生了錯誤了

    以下是在主機上安裝後的錯誤訊息,主要是執行setup檔後,就出現視窗說『應用程式驗證失敗』

    前輩們可以指導一下嗎?拜託拜託,我真的不知道錯在哪裡

     

    平台版本資訊
     Windows    : 5.2.3790.131072 (Win32NT)
     Common Language Runtime  : 2.0.50727.832
     System.Deployment.dll   : 2.0.50727.832 (QFE.050727-8300)
     mscorwks.dll    : 2.0.50727.832 (QFE.050727-8300)
     dfdll.dll    : 2.0.50727.42 (RTM.050727-4200)
     dfshim.dll    : 2.0.50727.42 (RTM.050727-4200)

    來源
     部署 URL   : file:///C:/Documents%20and%20Settings/keith/%E6%A1%8C%E9%9D%A2/AP200802021245/AP200802021245/APWaivePoint.application
     應用程式 URL   : file:///C:/Documents%20and%20Settings/keith/%E6%A1%8C%E9%9D%A2/AP200802021245/AP200802021245/APWaivePoint_1_0_0_22/APWaivePoint.exe.manifest

    識別
     部署識別  : APWaivePoint.application, Version=1.0.0.22, Culture=neutral, PublicKeyToken=94c93c9b42015b2b, processorArchitecture=msil
     應用程式識別  : APWaivePoint.exe, Version=1.0.0.22, Culture=neutral, PublicKeyToken=94c93c9b42015b2b, processorArchitecture=msil, type=win32

    應用程式摘要
     * 可安裝的應用程式。

    錯誤摘要
     下列為錯誤的摘要,這些錯誤的詳細資料稍後會列於記錄檔中。
     * 啟動 C:\Documents and Settings\keith\桌面\AP200802021245\AP200802021245\APWaivePoint.application 時發生例外狀況。 已偵測到下列失敗訊息:
      + 檔案 APWaivePoint.exe 的計算雜湊與資訊清單中指定的雜湊不同。

    元件存放區交易失敗摘要
     未偵測到交易錯誤。

    警告
     執行此作業時沒有警告。

    作業進度狀態
     * [2008/2/2 下午 12:49:47] : 已開始啟動 C:\Documents and Settings\keith\桌面\AP200802021245\AP200802021245\APWaivePoint.application。
     * [2008/2/2 下午 12:49:47] : 已成功完成部署資訊清單的處理。
     * [2008/2/2 下午 12:49:47] : 已開始應用程式的安裝。
     * [2008/2/2 下午 12:49:47] : 應用程式資訊清單的處理已順利完成。
     * [2008/2/2 下午 12:49:49] : 信任並偵測平台的要求完成。

    錯誤詳細資料
     執行此作業時,偵測到下列錯誤。
     * [2008/2/2 下午 12:49:49] System.Deployment.Application.InvalidDeploymentException (HashValidation)
      - 檔案 APWaivePoint.exe 的計算雜湊與資訊清單中指定的雜湊不同。
      - 來源: System.Deployment
      - 堆疊追蹤:
       於 System.Deployment.Application.ComponentVerifier.VerifyFileHash(String filePath, Hash hash)
       於 System.Deployment.Application.ComponentVerifier.VerifyFileHash(String filePath, HashCollection hashCollection)
       於 System.Deployment.Application.ComponentVerifier.FileComponent.Verify()
       於 System.Deployment.Application.ComponentVerifier.VerifyComponents()
       於 System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
       於 System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
       於 System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState subState, ActivationDescription actDesc)
       於 System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut)
       於 System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

    元件存放區交易詳細資料
     無可用的交易資訊。

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    webServices:

     

    using System;
    using System.Data;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Data.SqlClient;

    namespace WSWaivePointe
    {
        /// <summary>
        ///Service1 的摘要描述
        /// </summary>
        [WebService(Namespace = "http://XXX")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [ToolboxItem(false)]
        public class Service1 : System.Web.Services.WebService
        {

            #region 移除使用者免費點數
            [WebMethod(MessageName = "WaiveDate", Description = "移除免費點數.", EnableSession = false)]
            public string WaivePoint(string type, string WaiveDate)
            {
                SqlConnection sqlconn = new SqlConnection();
              

                SqlCommand sqlcmd;
                SqlDataAdapter sqlsda, sqlsda1;
                string sqlstr = "", connStr = "", user = "", sqlstr1 = "", sqlstr2 = "", sqlstr3 = "";
                int k = 0; //用來計算成功更改值得數

                connStr = "Data Source=.;Initial Catalog=xx;User ID=xx;Password=xx;";
                sqlconn = new SqlConnection(connStr);
                //sqlconn =new SqlConnection ();
                sqlconn.Open();

                //用來抓使用者id

                string bm = "";

                DateTime dt1 = DateTime.Now;
                bm = dt1.AddMonths(-1).ToString("yyyy/M/d"); //目前系統時間的前一個月日期

                sqlstr = "SELECT u.UserId, u.UserName, p.AccountBalance FROM aspnet_Users AS u INNER JOIN cs_UserProfile AS p ON u.UserId = p.MembershipID WHERE (u.UserName IN (SELECT DISTINCT payTo FROM inv_LedgerEntry WHERE (processCode = 'fla') AND (DATEDIFF(day, transDate, '2008/1/2') > 0) AND (DATEDIFF(day, transDate, '2007/12/30') <= 0) AND (payTo NOT IN (SELECT payTo FROM inv_LedgerEntry AS inv_LedgerEntry_1 WHERE (processCode IN ('newcc', 'oldcc', 'a', 'p', 'pv', 'ima', 'ta')) AND (DATEDIFF(day, transDate, '2007/12/30') <= 0)))))";

                sqlcmd = new SqlCommand(sqlstr, sqlconn);
                sqlsda = new SqlDataAdapter(sqlcmd);
                DataTable dt = new DataTable();
                sqlsda.Fill(dt);
                //建立transaction避免資料有誤
                SqlTransaction myTrans = sqlconn.BeginTransaction();
                sqlcmd.Transaction = myTrans;

                try
                {
                    if (dt.Rows.Count > 0) //判斷dt資料庫有資料時,才進行insert 和 update動作
                    {
                        for (int i = 0; i < dt.Rows.Count - 1; i++)
                        {

                            //System .Guid .NewGuid ().ToString () 產生此台電腦全球唯一的識別碼
                            //產生現在系統時間GetDate()
                            DateTime dtime = DateTime.Now;

                            sqlstr2 = "insert into inv_LedgerEntry(guid, owner_Id, transDate, reference,payTo, paymentMethod, currencyCode, amount, balancePrior, balanceAfter, categoryName, processCode, memo," +
                     " note, orderNumber, transactionType, transactionResult, cleared, modifier, lastModified, pntAcquired, pntPrior, pntAfter) values ('" + System.Guid.NewGuid().ToString() + "','" + System.Guid.NewGuid().ToString() +
                                "', GetDate()," + dtime.ToString("yyyyMM") + ",'" + dt.RowsIdea[1].ToString() + "','waive','NT'," + dt.RowsIdea[2].ToString() +
                                "," + dt.RowsIdea[2].ToString() + ",0,'waive','vf','vf','vf','',1,1,1,'service.e8d@fullerton.com.tw',"
                                + "GetDate(),-(" + dt.RowsIdea[2].ToString() + ")," + dt.RowsIdea[2].ToString() + ",0)";

                            //sqlcmd2=new SqlCommand (sqlstr2 ,sqlconn );
                            sqlcmd.CommandText = sqlstr2;
                            sqlcmd.ExecuteNonQuery();

                            //在insert into inv_LedgerEntry後,接下來就是update cs.UserProfile此資料表
                            //是直接把AccountBalance直接變成0嗎

    sqlstr2 = "update cs_UserProfile set accountBalance=0 where membershipID='"

    + dt.RowsIdea[0].ToString() + "'";
    sqlcmd.CommandText = sqlstr2;
                            sqlcmd.ExecuteNonQuery();

                            //更新成功回傳更新的筆數
                            k = i++;
                        }

                        //確定資料無誤,即commit;
                        myTrans.Commit();
                    }

                }
                catch (Exception ex)
                {
                    myTrans.Rollback();  //如果資料有誤則rollback,把剛剛已經輸入的資料全部都回復。
                    return Convert.ToString(-1);
                }
                finally { }
                sqlconn.Close();
                return k.ToString();
            }
            #endregion
        }
    }

     

    應用程式檔:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Configuration;
    using System.Windows.Forms;
    using System.IO;
    using System.Web.Services;
    using System.Data.SqlClient;
    using System.ServiceProcess;

    namespace APWaivePoint
    {
        public partial class frmWaivePoint : Form
        {

            private bool bFlag = false; //判斷timer是否被啟動
            public frmWaivePoint()
            {
                InitializeComponent();
            }

            private void frmWaivePoint_Load(object sender, EventArgs e)
            {
                timer1.Enabled = true;
                cbNoon.Enabled = false;
                cbbHour.Enabled = false;
                cbbMin.Enabled = false;
            }
            //bm為前一個月
            string bm;

            //開始執行刪除動作
            private void bStart_Click(object sender, EventArgs e)
            {
                timer1.Enabled = true;
              timer1.Interval = 1000 * 3600 * 3; //三小時就執行
              


            }

            private void StartWaive(string sDate)
            {

                DateTime dt = DateTime.Now;
                bm = dt.AddMonths(-1).ToString("yyyy/M/d");//目前系統時間的前一個月日期

                Int64 startTime = 0; //程式執行的時間
                Int64 endTime = 0;   //程式執行完的時間
                startTime = Environment.TickCount;
                string systemTime = System.DateTime.Now.ToString(); //完整時間
                string systemDate = System.DateTime.Now.ToString("yyyy/M/d");//日期
                //waivePointWS.Service1 ws = new WaivePointWS.waivePointWS.Service1();
                FullertonService.FtAccountingService ws=new FullertonService.FtAccountingService();
                ws.WaivePoint("fla", bm);
               
                //Directory.CreateDirectory("C:/WaivePoint");
                string path = "C:/WaivePointRecord.txt";
                //string path = "C:/WaivePoint/";
                FileInfo fi = new FileInfo(path); //建立FileInfo的函數
                StreamWriter sw = fi.AppendText();
                lbResult.Items.Clear();
                //刪除資料開始,並在lbResult.txt上開始紀錄過程
                lbResult.Items.Add("*******************************************************************");
                lbResult.Items.Add("[" + systemTime + "]-開始進行資料刪除");
                endTime = Environment.TickCount;
                Int64 exeTime = (endTime - startTime) / 1000;
                lbResult.Items.Add("[共花費" + exeTime + "秒刪除資料]-成功刪除共計" + ws.WaivePoint("fla",bm) + "則資料"); //刪除fla形式的點數和時間為前一個月
                lbResult.Items.Add("[資料刪除已結束]");
                lbResult.Items.Add("*******************************************************************");
                lbResult.Items.Add(" ");
                lbResult.Items.Add(" ");
                for (int i = 0; i < lbResult.Items.Count - 1; i++)
                {
                    sw.WriteLine(lbResult.ItemsIdea.ToString() + "\r\n");
                } //寫入
                sw.Flush();// 將緩衝區資料寫入檔案
                sw.Close();
                bEnd.Enabled = true;
            }

            private void timer1_Tick(object sender, EventArgs e)
            {

                DateTime dt = DateTime.Now;
                bm = dt.AddMonths(-1).ToString("yyyy/M/d"); //目前系統時間的前一個月日期
                string nowTime = System.DateTime.Now.ToLongTimeString();
                lblDate.Text = nowTime;
                try
                {
                    FullertonService.FtAccountingService ws = new FullertonService.FtAccountingService();
                    ws.WaivePoint("fla", bm);
                    StartWaive(bm);
                }
                catch(Exception ex)
                {
                    string path = "C:/error.txt";
                    //string path = "C:/WaivePoint/";
                    FileInfo fi = new FileInfo(path); //建立FileInfo的函數
                    StreamWriter sw = fi.AppendText();
                    sw.WriteLine(ex.ToString());
                    sw.Flush();
                    sw.Close();
                }
               
            }

            //停止web Services的服務
            private void bEnd_Click(object sender, EventArgs e)
            {
                ServiceController sc = new ServiceController("WSWaivePoint");
                if ((sc.Status.Equals(ServiceControllerStatus.Stopped)) ||
         (sc.Status.Equals(ServiceControllerStatus.StopPending))) 
                {
                    MessageBox.Show("停止刪除");
               
                }
            }

           

            //當選立即執行,則時間不能用
            private void rbRightWay_CheckedChanged(object sender, EventArgs e)
            {  
                cbNoon.Enabled = false;
                cbbHour.Enabled = false;
                cbbMin.Enabled = false;
            }
            //當選排程執行,則時間可用
            private void rbArrange_CheckedChanged(object sender, EventArgs e)
            {
                cbNoon.Enabled = true;
                cbbHour.Enabled = true;
                cbbMin.Enabled = true;
            }       
        }
    }

    2008年2月2日 上午 05:00

解答

所有回覆

  • HI,

     

    您的XML Web Service有加上簽署嗎? 從錯誤訊息來看是程式和資訊清單的雜湊不同:

     

    [APWaivePoint.exe 的計算雜湊與資訊清單中指定的雜湊不同]

     

    建議[重新建置]XML Web Service後再部署

     

    tihs

    2008年2月4日 上午 12:57
  • 嗯嗯!謝謝您!前輩!

    我把它整個複製到另一個專案後,執行就可以了

    可是問題是?這是我的程式有錯誤

    還是微軟包裝的問題呢?

     

     

    2008年2月5日 上午 03:33
  • HI,

     

    有可能是部署之後又修改過XML WEB SERVICE的CODE造成的

     

    tihs

    2008年2月6日 下午 12:55