Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Using a Button I have defined a function:

private void newButton_Click(object sender, System.EventArgs e)
{
isNew = true;
isNewListe = false;
//.....
}

There is a breakpoint set where isNew = true; - that means at the very first line of this procedure

In Debug Mode pressing the new Button I dont reach the breakpoint, the program is quitting at the moment of clicking New

Any reason for that? Please help!
MiKR41
Posted
Comments
G-code101 5-Feb-14 11:16am    
Isn't it obvious? Right after the button is clicked the application will exit because you have set the breakpoint at the click portion... Basically the newButton_Click event is handled at that point, try setting the breakpoint at "isNewListe = false;" and right before that put this line in

Console.WriteLine(isNew);

To illustrate my point the output window will display isNew Value which is static "true" and the app will stop running and break just after that so to sum it up do this...

private void newButton_Click(object sender, System.EventArgs e)
{
isNew = true;
Console.WriteLine(isNew);
// PUT YOUR BREAKPOINT AT NEXT LINE!!!
isNewListe = false;
//.....
}

So in conclusion you keep reaching that specific breakpoint without knowing it... After it breaks go to the visual studio app and view what it shows you... Notice the difference.
ZurdoDev 5-Feb-14 13:43pm    
This does not sound right. They say the application quits when clicking New and his breakpoint is not hit.
G-code101 6-Feb-14 0:46am    
According to my understanding... that the breakpoint is set right after the button is clicked, there is no other way mentioned in his code to verify that the breakpoint was ever hit, hence I supplied him with a visual confirmation if you will...
Matt T Heffron 6-Feb-14 14:48pm    
With all due respect...this is nonsense.
OP set the breakpoint on an executable line of code; the debugger should stop at that line.
It seems more likely that the event is not correctly "hooked-up"
G-code101 7-Feb-14 0:53am    
He found the problem... Apparently the dll was not re-referenced after he changed it so it still worked on an old method of btn_New_Click and btn_NewList_Click Events.

Check if you have registered the same event on button click in ASPX.

Paste some more code for better idea. This is not enough for the clue.
 
Share this answer
 
Comments
G-code101 5-Feb-14 11:25am    
He/she is trying to figure out why the application is stopping at the breakpoint but he/she is not picking it up on the event
Member 10284036 5-Feb-14 14:18pm    
Thank you for your reply. How could I check, if the event is registered in ASPX? I tried to rename the button and the event, it does not work, at the console was written nothing. It seems to me, that (previously the procedure was doing perfectly well, and I didnot change anything in this File, only in a referenced DLL I changed a minor thing, which I removed after the problem) that for any silly reason the click is interpreted as a close();? Thanks in advance MiKr41
Hiren2 P 6-Feb-14 1:24am    
Check you have any event registered below way:
OnClick="buttonName_Click"
G-code101 6-Feb-14 0:48am    
What do you mean by you made changes in the referenced dll? Remove all breakpoints in your app and debug again, let me know what happens...
Member 10284036 6-Feb-14 5:15am    
There are a lot of different buttons defined, a selection is shown:
//
// grafikButton
//
this.grafikButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grafikButton.Location = new System.Drawing.Point(216, 336);
this.grafikButton.Name = "grafikButton";
this.grafikButton.Size = new System.Drawing.Size(88, 24);
this.grafikButton.TabIndex = 7;
this.grafikButton.Text = "&Grafik";
this.grafikButton.Click += new System.EventHandler(this.grafikButton_Click);
//
// btn_New
//
this.btn_New.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_New.Location = new System.Drawing.Point(320, 336);
this.btn_New.Name = "btn_New";
this.btn_New.Size = new System.Drawing.Size(88, 24);
this.btn_New.TabIndex = 9;
this.btn_New.Text = "N&eu";
this.btn_New.Click += new System.EventHandler(this.btn_New_Click);
//
// btn_NewList
//
this.btn_NewList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_NewList.Location = new System.Drawing.Point(320, 368);
this.btn_NewList.Name = "btn_NewList";
this.btn_NewList.Size = new System.Drawing.Size(88, 24);
this.btn_NewList.TabIndex = 10;
this.btn_NewList.Text = "Neu (&Liste)";
this.mainTip.SetToolTip(this.btn_NewList, "Es erfolgt eine Auswahl der definierten Listen, die ein Fenster mit den Eingabefe" +
"ldern erzeugen.");
this.btn_NewList.Click += new System.EventHandler(this.btn_NewList_Click);

The problem is, that every button is acting as it should but only two - the btn_New and the btn_NewList shows this strange behaviour.

The whole Coding of the response to the Click is as follows:
private void btn_New_Click(object sender, System.EventArgs e)
{
isNew = true;
Console.WriteLine(isNew);
isNewListe = false;
inputDatum = dt.Heute();
inputTime = dt.Jetzt();
editBox.Visible = false;
ergEdit.Visible = false;
zeitEdit.Visible = false;
editBox.Items.Clear();
laborListe.Visible = false;
overViewListe.Visible = false;
laborListe.Items.Clear();
nextButton.Visible = false;
prevButton.Visible = false;
overViewButton.Visible = false;
printButton.Visible = false;
grafikButton.Visible = false;
copyButton.Visible = false;
btn_New.Visible = false;
btn_NewList.Visible = false;
editButton.Text = "Weiter";
deleteButton.Text = "Sichern";
deleteButton.Visible = false;
panelSingel.Visible = true;
cancelButton.Visible = true;
grpBox.Items.Clear();
MySqlDataAdapter DBPar = new MySqlDataAdapter("select distinct Gruppe from laborparameter order by Gruppe", DBC);
DataSet sPar = new DataSet();
if (DBPar.Fill(sPar) > 0)
{
foreach(DataRow dr in sPar.Tables[0].Rows)
{
grpBox.Items.Add(dr["Gruppe"].ToString().TrimEnd(' '));
}
}
if (grpBox.Items.Count > 0)
{
grpBox.SelectedIndex = 0;
}
}

The environment: this dll is embedded in a calling dll which too is called by the main program. The whole package consists of about 70 dll's. This is the f
Dear G-code 101 - I found it. First I wrote a small program calling the questioned DLL - everything worked fine. Next step: call the calling dll, do the click on btn_new there was a missing dll announced (in the references it was still there!) I removed the dll and bound it again, doing the same in the main program the error is gone. This means, everytime you are changing a frequently used dll you would have to remove all references and bind it again to all program parts!?
Thank you for your advice
MiKr41
 
Share this answer
 
Comments
G-code101 7-Feb-14 1:02am    
That's one hundred percent correct

let's say your previous dll has a function that states this as an example,


private void btn_New_Click(object sender,System.EventArgs e)
{
this.close;
}


And you changed it to this after it has been referenced as an example,


private void btn_New_Click(object sender,System.EventArgs e)
{
console.writeline("This is a test!");
}


The second function will never be used since the new dll was never referenced.

I'm glad you figured it out :-)!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900