通过installshield在VS2012中最终制作可执行的安装文件,但每次都失败

本文关键字:文件 安装 失败 可执行 VS2012 installshield 通过 | 更新日期: 2023-09-27 18:18:01

我已经在c#中做了一个提醒应用程序,现在我想创建它的安装程序以安装在其他pc上,但每次我使用Flexera install-shield创建安装程序时,它都会创建一个从未安装的文件!!我确信我做的是正确的告诉教程。我的应用程序包含2个表单,下面是代码:

第一页
 public partial class Form1 : Form
{
    RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE''Microsoft''Windows''CurrentVersion''Run", true);
    private NotifyIcon m_notifyicon;
    private ContextMenu m_menu;
    EntryForm ef = new EntryForm();
    public Form1()
    {
        Text = "TrayIcon test program";
        m_menu = new ContextMenu();
        m_menu.MenuItems.Add(0,
            new MenuItem("Show", new System.EventHandler(Show_Click)));
        m_menu.MenuItems.Add(1,
            new MenuItem("Hide", new System.EventHandler(Hide_Click)));
        m_menu.MenuItems.Add(2,
            new MenuItem("Exit", new System.EventHandler(Exit_Click)));
        m_notifyicon = new NotifyIcon();
        m_notifyicon.Text = "Right click for context menu";
        m_notifyicon.Visible = true;
        //m_notifyicon.Icon = new Icon(GetType(), "Icon1.ico");
        m_notifyicon.Icon = new Icon(@"C:'ic.ico");
        m_notifyicon.ContextMenu = m_menu;
        ef.Activate();
        reg.SetValue("Reminder_App_Varun", Application.ExecutablePath.ToString());
        InitializeComponent();
        this.StartPosition = FormStartPosition.Manual;
        this.Location = new Point(500, 220);
    }
    protected void Exit_Click(Object sender, System.EventArgs e)
    {
        Close();
    }
    protected void Hide_Click(Object sender, System.EventArgs e)
    {
        Hide();
    }
    protected void Show_Click(Object sender, System.EventArgs e)
    {
        Show();
    }
    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            this.m_notifyicon.Dispose();
        }
        base.Dispose(disposing);
    }
    [STAThread]
    static void Main1()
    {
        Application.Run(new Form1());
    }

第二种形式

public partial class EntryForm : Form
{
    public EntryForm()
    {
        InitializeComponent();
        label9.Hide();
        panel2.Hide();
        configmail();
        cdate();
        checkdate();            
        grid_bind();
        panel4.Hide();
        label14.Text = "No Selection";
        this.label11.Click += new System.EventHandler(this.ctrlClick);
    }
    private void ctrlClick(System.Object sender, EventArgs e)
    {
        Control ctrl = (Control)sender;       
        panel4.Show();
    }
    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if (m.Msg == WM_NCHITTEST)
            m.Result = (IntPtr)(HT_CAPTION);
    }
    private const int WM_NCHITTEST = 0x84;
    private const int HT_CLIENT = 0x1;
    private const int HT_CAPTION = 0x2;
    private void button2_Click(object sender, EventArgs e)
    {
        checkdate();
    }
    private void checkdate()
    {
        DateTime dt = DateTime.Parse(label10.Text);
        long t = dt.ToFileTime();
        DateTime date1 = DateTime.Today;     
        int result = DateTime.Compare(date1, dt);
        string relationship;
        if (result > 0)
        {
            relationship = "is earlier than";                   
        }
        else if (result == 0)
        {
            relationship = "is later than";
            SendEmail();               
        }
        else
        {
            relationship = "is later than";
            SendEmail();                
        }
        Console.WriteLine("{0} {1} {2}", date1, relationship, dt);
    }
    private void SendEmail()
    {
        try
        {
            OleDbConnection ncon = new OleDbConnection();
            ncon.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
            ncon.Open();
            OleDbCommand ncmd = new OleDbCommand("SELECT * FROM tb_sendmail WHERE (((remind_date)=#" + label13.Text + "#))", ncon);
            OleDbDataAdapter da = new OleDbDataAdapter(ncmd);
            DataTable ndt = new DataTable();
            da.Fill(ndt);
            //...FOR ERROR 5.5.1 SECURE CONNECTION GO TO https://www.google.com/settings/security/lesssecureapps AND TURN ON LESS SECURE APPS CONNECTION...////
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.Port = 587;
            client.EnableSsl = true;
            client.Timeout = 100000;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential("" + label7.Text + "", "" + label9.Text + "");       
            MailMessage msg = new MailMessage();
            msg.To.Add("" + ndt.Rows[0][1].ToString() + "");              
            msg.From = new MailAddress("vari.v5@gmail.com");        
            msg.Subject = (""+ndt.Rows[0][2].ToString()+"");        
            msg.Body = ("" + ndt.Rows[0][4].ToString() + "");             
            client.Send(msg);
            MessageBox.Show("Successfully Sent Message.");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    private void button1_Click(object sender, EventArgs e)
    {
        this.Hide();
    }
    private void panel1_Paint(object sender, PaintEventArgs e)
    {
    }
    private void panel2_Paint(object sender, PaintEventArgs e)
    {


    }
    private void button3_Click(object sender, EventArgs e)//--------------email send pannel--------------//
    {
        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
        con.Open();            
        OleDbCommand cmd = new OleDbCommand("Insert into tb_sendmail (email_add,subject,remind_date,message) values (@email_add,@subject,@remind_date,@message)", con);
        if (con.State == ConnectionState.Open)    
        {
            cmd.Parameters.Add("@email_add", OleDbType.VarChar).Value = textBox1.Text;
            cmd.Parameters.Add("@subject", OleDbType.VarChar).Value = textBox2.Text;
            cmd.Parameters.Add("@remind_date", OleDbType.Date).Value = textBox3.Text;
            cmd.Parameters.Add("@message", OleDbType.VarChar).Value = textBox4.Text;
            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("DATA ADDED");
                dataGridView1.Refresh();
                con.Close();
            }
            catch (OleDbException expe)
            {
                MessageBox.Show(expe.Message);
                con.Close();
            }
        }
        grid_bind();
    }
    private void grid_bind()
    {
        OleDbConnection conn = new OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
        conn.Open();                     
        OleDbDataAdapter oda;
        DataTable ndt;
        oda = new OleDbDataAdapter("SELECT ID,email_add,subject,remind_date,message from tb_sendmail", conn);
        ndt = new DataTable();
        oda.Fill(ndt);
        dataGridView1.DataSource = ndt;
    }
    private void button4_Click(object sender, EventArgs e)//--------------email address details pannel--------------//
    {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
            con.Open();
            OleDbCommand cmd = new OleDbCommand("Update tb_email set email_address=@email_address,email_password=@email_password where ID = 1", con);
            if (con.State == ConnectionState.Open)   
            {
                cmd.Parameters.Add("@email_address", OleDbType.VarChar).Value = textBox5.Text;
                cmd.Parameters.Add("@email_password", OleDbType.VarChar).Value = textBox6.Text;
                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Email Address Saved Successfully");
                    con.Close();
                    panel2.Hide();
                    label7.Refresh();
                    button5.Show();
                }
                catch (OleDbException expe)
                {
                    MessageBox.Show(expe.Message);
                    con.Close();
                }
            }
    }
    private void button5_Click(object sender, EventArgs e)
    {
        panel2.Show();
        button5.Hide();
    }       
    private void cdate()
    {
        DateTime dat = DateTime.Now;            
        label13.Text = dat.ToString("MM/dd/yyyy");            
        OleDbConnection ncon = new OleDbConnection();
        ncon.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
        ncon.Open();
        OleDbCommand ncmd = new OleDbCommand("SELECT * FROM tb_sendmail WHERE (((remind_date)=#" + label13.Text + "#))", ncon);            
        OleDbDataAdapter da = new OleDbDataAdapter(ncmd);
        DataTable ndt = new DataTable();
        da.Fill(ndt);
        if (ndt.Rows.Count == 0 )
        {
            label10.Text = "01-09-2015";
        }
        else if (ndt.Rows.Count > 0)
        {
            MessageBox.Show(" TODAY is "+ label13.Text +", Perform your set action. Reminder has been sent on your Email. !");
            label10.Text = ndt.Rows[0][3].ToString();            
            }
        else
        {
        label10.Text = ndt.Rows[0][3].ToString(); 
        }
    }
    private void configmail()
    {
        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
        con.Open();
        OleDbCommand cmd = new OleDbCommand("Select * from tb_email", con);
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        label7.Text = dt.Rows[0][1].ToString();
        label9.Text = dt.Rows[0][2].ToString();
    }
    private void EntryForm_Load(object sender, EventArgs e)
    {
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
    }
    private void button8_Click(object sender, EventArgs e)//---------clear text-------//
    {
        clear_textbox();
    }
    private void clear_textbox()
    {
        textBox1.Text = "";
        textBox2.Text = "";
        textBox3.Text = "";
        textBox4.Text = "";
    }
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        textBox1.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
        textBox2.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
        textBox3.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
        textBox4.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
        label14.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
    }
    private void button6_Click(object sender, EventArgs e)
    {
    }
    private void button7_Click(object sender, EventArgs e)
    {
        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|'RemindMe Beta 1.0'RemindMe Beta 1.0'sendmail.accdb";
        con.Open();            
        OleDbCommand cmd = new OleDbCommand("Delete from tb_sendmail where ID = @ID", con);
        if (con.State == ConnectionState.Open)
        {
            cmd.Parameters.Add("@ID", OleDbType.Integer).Value = label14.Text;
            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("DATA Deleted !!");
                con.Close();
            }
            catch (OleDbException expe)
            {
                MessageBox.Show(expe.Message);
                con.Close();
            }
        }
        else
        {
            MessageBox.Show("CON FAILED");
        }
        grid_bind();
        clear_textbox();
    }
    private void dataGridView1_SelectionChanged(object sender, EventArgs e)
    {
        label14.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
    }
    private void button6_Click_1(object sender, EventArgs e)
    {
        panel4.Hide();
    }
}

我也附上我的代码文件:http://www.4shared.com/rar/Kh34lfL7ce/RemindMe_Beta_10.html

我是一个新手,这是我的第一个项目,所以请指出我的错误。

谢谢

通过installshield在VS2012中最终制作可执行的安装文件,但每次都失败

我注意到这可能是因为你在错误的时间打电话给InitializeComponent();