简体   繁体   English

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

[英]making executable setup file in VS2012 ulitimate via installshield but getting failed everytime

i have made a reminder application in C#, now i want to create setup of it to install it on other PCs but everytime i create setup using Flexera install-shield, it creates a file which never installs !! 我已经在C#中创建了一个提醒应用程序,现在我想创建它的安装程序以将其安装在其他PC上,但是每次我使用Flexera install-shield创建安装程序时,它都会创建一个从未安装的文件! i am sure i am doing it correct as told in tutorials. 我确信我按照教程中的说明做的正确。 My application contains 2 Forms here is the code: 我的应用程序包含2个表单,这里是代码:

First Page 第一页

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

Second Form 第二形式

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

}

I am also attaching my code file : http://www.4shared.com/rar/Kh34lfL7ce/RemindMe_Beta_10.html 我还附加了我的代码文件: http : //www.4shared.com/rar/Kh34lfL7ce/RemindMe_Beta_10.html

I am a noob and it is my first project so please highlight my mistakes in it. 我是菜鸟,这是我的第一个项目,所以请强调我在其中的错误。

Thanks 谢谢

I noticed that it's probably because you call InitializeComponent(); 我注意到这可能是因为您调用了InitializeComponent(); at the wrong moment. 在错误的时刻。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM