Pb firing events with VC 2005

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,
Still having problems with converting my VC 2003
project to VC 2005 beta, this time with events (using the new
C++ syntax).

My class defines the following event:
event PropertyChangedEventHandler ^ PropertyChanged;

(it uses the System.ComponentModel.PropertyChangedEventHandler delegate)

When I try to fire the event:
PropertyChanged(this, gcnew PropertyChangedEventArgs("Size"));

I get a 'System.NullReferenceException'

If I look in the "Autos" Debug window, I see:

- this
<PropertyChanged> <undefined value>


Is it normal ?
What am I doing wrong ?

Chris.
 
Chris,
Still having problems with converting my VC 2003
project to VC 2005 beta, this time with events (using the new
C++ syntax).

My class defines the following event:
event PropertyChangedEventHandler ^ PropertyChanged;

(it uses the System.ComponentModel.PropertyChangedEventHandler delegate)

When I try to fire the event:
PropertyChanged(this, gcnew PropertyChangedEventArgs("Size"));

I get a 'System.NullReferenceException'

If I look in the "Autos" Debug window, I see:

- this
<PropertyChanged> <undefined value>


Is it normal ?
What am I doing wrong ?

Do you have any delegates attached to this event? Usually, when coding calls
to an event, you always need to check if it is null first (in which case no
one has subscribed to the event yet)
In the end, the event is only a multicast delegate with another extra piece
of metadata...
 
Tomas said:
Do you have any delegates attached to this event? Usually, when coding calls
to an event, you always need to check if it is null first (in which case no
one has subscribed to the event yet)
In the end, the event is only a multicast delegate with another extra piece
of metadata...

OK. I hadn't realized that the value of the delegate
should be tested. I had no receiver connected to the event.
Thanks.
 
Back
Top