By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

Pb firing events with VC 2005

P: n/a
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.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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 Restrepo
to****@mvps.org
Nov 17 '05 #2

P: n/a
Tomas Restrepo (MVP) wrote:
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.
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.