I have a class (Class A) that displays a form built from
scratch with data from xml files. (Class A) creates an
array of LinkLabel's that are created and "added" to by
the LinkLabelArray's class methods (Class B).
When the user selected a link, the clickhandler was in
(Class B) where the link arrays methods are, and the
screen stayed up for the user to close.
So, in the loop in (Class A) I added:
this.arrayLinkControl[storyNode].Click += new
System.EventHandler(LinkLabelClickHandler);
LinkLabelClickHandler exists as a method in (Class A).
Now, this works just fine and dandy however..when you
click on the link, the method does this:
private void LinkLabelClickHandler(
Object sender, System.EventArgs e)
{
string strVisitUrl =
((System.Windows.Forms.LinkLabel)sender).Text.Trim ();
System.Diagnostics.Process.Start(strVisitUrl);
this.Close();
}
Which *does* fire up IE and brings the user to the page
but then I get:
An unhandled exception of
type 'System.ObjectDisopsedException' occured
Cannot access a disposed object named "LinkLabel"
What am I doing majorly wrong here? I got fed up and
threw a try{} with an empty catch{} around it but I would
think I'm only asking for major trouble then.