C#项目错误:“已添加具有相同键的项目”

时间:2010-09-30 08:19:16

标签: c# installation

我有一个使用C#(visual studio 2008)和sql server 2000的项目。我在三台计算机上安装了这个项目设置。它正确地在其中两个(xp sp3)中工作,但在其他方面不起作用(xp最终)。只打开一个表单时会出错:“已经添加了具有相同键的项目” 我该如何解决这个问题?

源代码:

    DBClass db = new DBClass();
    private void FrmGiris_Load(object sender, EventArgs e)
    {           
        string sorgu = "select top 50 * from IsTakipDetay where Asama='Yapılacak'";          
        DataTable data = db.DBSelect(sorgu);

        if (schedulerStorage1.Appointments.Count > 0)
            schedulerStorage1.Appointments.Clear();

        for (int i = 0; i < data.Rows.Count; i++)
        {
            DevExpress.XtraScheduler.Appointment app = new DevExpress.XtraScheduler.Appointment();
            app.Start = Convert.ToDateTime(data.Rows[i]["Saat"]);
            app.End = Convert.ToDateTime(data.Rows[i]["Saat"]);
            app.Subject = data.Rows[i]["IsAdi"].ToString() + "-" + data.Rows[i]["DetayAdi"].ToString();

            DataTable dt = db.DBSelect("select MusteriAdi,Adres from IsTakip where Id=" + Convert.ToInt32(data.Rows[i]["IsId"]));
            if (dt.Rows.Count > 0)
            {
                app.Location = dt.Rows[0]["Adres"].ToString();
                app.Description = "Müşteri Adı: " + dt.Rows[0]["MusteriAdi"].ToString() + " / Personel Adı:" + data.Rows[i]["PersonelAdi"].ToString();
            }
            schedulerStorage1.Appointments.Add(app);
        }
    }

设计师代码:

 #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmAjanda));
        DevExpress.XtraScheduler.TimeRuler timeRuler1 = new DevExpress.XtraScheduler.TimeRuler();
        DevExpress.XtraScheduler.TimeRuler timeRuler2 = new DevExpress.XtraScheduler.TimeRuler();
        this.schedulerStorage1 = new DevExpress.XtraScheduler.SchedulerStorage(this.components);
        this.ısTakipDetayBindingSource = new System.Windows.Forms.BindingSource(this.components);
        this.dSet = new Dogalgaz.dSet();
        this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
        this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
        this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
        this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
        this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
        this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
        this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl();
        this.navBarControl1 = new DevExpress.XtraNavBar.NavBarControl();
        this.navBarGroup1 = new DevExpress.XtraNavBar.NavBarGroup();
        this.itemGunluk = new DevExpress.XtraNavBar.NavBarItem();
        this.itemHafta = new DevExpress.XtraNavBar.NavBarItem();
        this.itemAylik = new DevExpress.XtraNavBar.NavBarItem();
        this.itemCizelge = new DevExpress.XtraNavBar.NavBarItem();
        this.navBarGroupControlContainer1 = new DevExpress.XtraNavBar.NavBarGroupControlContainer();
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        this.radioIs = new System.Windows.Forms.RadioButton();
        this.radioPersonel = new System.Windows.Forms.RadioButton();
        this.radioTum = new System.Windows.Forms.RadioButton();
        this.comboKriter = new DevExpress.XtraEditors.ComboBoxEdit();
        this.labelKriter = new System.Windows.Forms.Label();
        this.navBarGroupControlContainer2 = new DevExpress.XtraNavBar.NavBarGroupControlContainer();
        this.dateNavigator1 = new DevExpress.XtraScheduler.DateNavigator();
        this.schedulerControl1 = new DevExpress.XtraScheduler.SchedulerControl();
        this.navBarGroup3 = new DevExpress.XtraNavBar.NavBarGroup();
        this.navBarItem2 = new DevExpress.XtraNavBar.NavBarItem();
        this.navBarItem3 = new DevExpress.XtraNavBar.NavBarItem();
        this.navBarItem1 = new DevExpress.XtraNavBar.NavBarItem();
        this.navBarGroup2 = new DevExpress.XtraNavBar.NavBarGroup();
        this.itemYazdirPencer = new DevExpress.XtraNavBar.NavBarItem();
        this.itemPrintPreview = new DevExpress.XtraNavBar.NavBarItem();
        this.itemPrint = new DevExpress.XtraNavBar.NavBarItem();
        this.navBarGroup4 = new DevExpress.XtraNavBar.NavBarGroup();
        ((System.ComponentModel.ISupportInitialize)(this.schedulerStorage1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.ısTakipDetayBindingSource)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.dSet)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit();
        this.splitContainerControl1.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.navBarControl1)).BeginInit();
        this.navBarControl1.SuspendLayout();
        this.navBarGroupControlContainer1.SuspendLayout();
        this.groupBox1.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.comboKriter.Properties)).BeginInit();
        this.navBarGroupControlContainer2.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.dateNavigator1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.schedulerControl1)).BeginInit();
        this.SuspendLayout();
        // Other controls codes//////////////////////
         //
        // FrmAjanda
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(974, 562);
        this.Controls.Add(this.splitContainerControl1);
        this.Name = "FrmAjanda";
        this.Text = "DOĞALGAZ TAKİP - AJANDA";
        this.Load += new System.EventHandler(this.FrmGiris_Load);
        ((System.ComponentModel.ISupportInitialize)(this.schedulerStorage1)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.ısTakipDetayBindingSource)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.dSet)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit();
        this.splitContainerControl1.ResumeLayout(false);
        ((System.ComponentModel.ISupportInitialize)(this.navBarControl1)).EndInit();
        this.navBarControl1.ResumeLayout(false);
        this.navBarGroupControlContainer1.ResumeLayout(false);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        ((System.ComponentModel.ISupportInitialize)(this.comboKriter.Properties)).EndInit();
        this.navBarGroupControlContainer2.ResumeLayout(false);
        ((System.ComponentModel.ISupportInitialize)(this.dateNavigator1)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.schedulerControl1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.BindingSource ısTakipDetayBindingSource;
    private dSet dSet;
    private System.Data.SqlClient.SqlConnection sqlConnection1;
    private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
    private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
    private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
    private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
    private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
    private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1;
    private DevExpress.XtraNavBar.NavBarControl navBarControl1;
    private DevExpress.XtraNavBar.NavBarGroup navBarGroup1;
    private DevExpress.XtraNavBar.NavBarItem itemGunluk;
    private DevExpress.XtraNavBar.NavBarItem itemHafta;
    private DevExpress.XtraNavBar.NavBarItem itemAylik;
    private DevExpress.XtraNavBar.NavBarItem itemCizelge;
    private DevExpress.XtraNavBar.NavBarGroup navBarGroup2;
    private DevExpress.XtraNavBar.NavBarItem itemYazdirPencer;
    private DevExpress.XtraNavBar.NavBarItem itemPrintPreview;
    private DevExpress.XtraNavBar.NavBarItem itemPrint;
    private DevExpress.XtraScheduler.SchedulerControl schedulerControl1;
    public DevExpress.XtraScheduler.SchedulerStorage schedulerStorage1;
    private DevExpress.XtraNavBar.NavBarItem navBarItem1;
    private DevExpress.XtraNavBar.NavBarGroup navBarGroup3;
    private DevExpress.XtraNavBar.NavBarItem navBarItem3;
    private DevExpress.XtraNavBar.NavBarItem navBarItem2;
    private DevExpress.XtraNavBar.NavBarGroupControlContainer navBarGroupControlContainer1;
    private System.Windows.Forms.GroupBox groupBox1;
    private DevExpress.XtraEditors.ComboBoxEdit comboKriter;
    private System.Windows.Forms.Label labelKriter;
    private System.Windows.Forms.RadioButton radioIs;
    private System.Windows.Forms.RadioButton radioPersonel;
    private System.Windows.Forms.RadioButton radioTum;
    private DevExpress.XtraNavBar.NavBarGroupControlContainer navBarGroupControlContainer2;
    private DevExpress.XtraScheduler.DateNavigator dateNavigator1;
    private DevExpress.XtraNavBar.NavBarGroup navBarGroup4;
}

}

但问题在于,它适用于两台计算机(xp sp3),但没有第三台(xp终极版)为什么?

只是这个表单给出错误其他表单正常工作。

可能是因为操作系统?

1 个答案:

答案 0 :(得分:0)

似乎每个表单加载时,该失败表单上的一个控件都会将对象添加到列表/字典中。设计者将第二行添加到设计器文件中,下次加载表单时,它会因错误而失败。

所以请发布表单的设计器部分。