Event undefined value at runtime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have 3 classes, class 1 has reference to class 2, class 2 has reference to class 3. i want to pass a value from class 3 to class 1, so 3 creates an event, 2 handels it then creates another event which 1 handels
the code for creating and handeling between each is the same except for the names however 3 -> 2 works but 2 -> 1 always failes with object not set to instance error. in debug it shows the event is set to undefined value.

In debug if i break after 1 sets the handel for 2 and go throguth the instance of 2 to see the event it does have a valid value, however when it gets to that part of 2 it nolonger has that value

so why is 3-2 working but not 2-1 when the code is almsot identical... i have event rewritten all the stuff with different names and its still the same
i have

Namespace

public delegate void MenuRefreshHandler(object o, ArrayList a)

class

private class2 c2
class1(

c2 = new c2()
c2.EventPassMenuRefresh += new MenuRefreshHandler(this.catchthing)


public void catchthing(object o, ArrayList a

//display cod




class

private class3 c3
public event MenuRefreshHandler EventPassMenuRefresh
class2(

c3 = new c3()
c3.EventMenuRefresh += new MenuRefreshHandler(this.MenuRefresh)


public void MenuRefresh(object o, ArrayList a

EventPassMenuRefresh(o,a)






namespace

class

public event MenuRefreshHandler EventMenuRefresh
class3(

/


public void eventmethod(

//stuf
EventMenuRefresh(null, al)



}
 
Spike said:
i have 3 classes, class 1 has reference to class 2, class 2 has
reference to class 3. i want to pass a value from class 3 to class 1,
so 3 creates an event, 2 handels it then creates another event which
1 handels, the code for creating and handeling between each is the
same except for the names however 3 -> 2 works but 2 -> 1 always
failes with object not set to instance error. in debug it shows the
event is set to undefined value.

In debug if i break after 1 sets the handel for 2 and go throguth the
instance of 2 to see the event it does have a valid value, however
when it gets to that part of 2 it nolonger has that value.

so why is 3-2 working but not 2-1 when the code is almsot
identical... i have event rewritten all the stuff with different
names and its still the same.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

(The code you posted doesn't give enough information to reproduce the
problem.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top