[Mono-osx] Why a Null Value

Eric Hosick erichosick at gmail.com
Sat Aug 27 13:57:17 EDT 2011


Hi All,

Sorry to send out so many emails so close together. Problem is partially
solved but don't know why (and I think I may be using the wrong mailing list
too).

I added to the constructor of AggregateHashtable the line p_wrappedInstance
= new Hashtable(); (leaving in the initialization of the p_wrappedInstance
private attribute). Complied and it WORKED (no more null for
p_wrappedInstance). I then commented out that line and it still worked.
Weird...

However, this same problem is now happening with another class that has
similar code: wrapping an instance (in this case a Stack). It should never
be null, but is later in the code. I tried the above actions and it did not
work: still null (even though attribute is private, never accessed anywhere
else, etc.)

So, weird behavior going on.

(Note: I am using Lion 10.7.1, MonoDevelop 2.4.2, Mono 2.10.5).

Regards,

Eric

On Sun, Aug 28, 2011 at 12:02 AM, Eric Hosick <erichosick at gmail.com> wrote:

> Doh. Sent before I was finished...
>
> On Sun, Aug 28, 2011 at 12:00 AM, Eric Hosick <erichosick at gmail.com>wrote:
>
>> Hi All,
>>
>> I have the following code:
>>
>> class AggregateHashtable {
>>   private Hashtable p_wrappedInstance = new Hashtable();
>>
>>   public AggregateHashtable() {
>>     if ( null == p_wrappedInstance ) {
>>       throw new Exception ("How did this get to be null?"); // Just to
>> check if this is ever happening.
>>     }
>>   }
>>    [XmlIgnore] public Hashtable wrappedInstance {
>>     get { return p_wrappedInstance; }
>>   }
>>
>>   // other code but never accesses p_wrappedInstance
>> }
>>
>> During runtime somewhere in the code:
>>
>>   get {
>>   AggregateHashtable iHashTable = ccmRoot.root as AggregateHashtable;
>>   if ( null == iHashTable.wrappedInstance ) {
>>   throw new Exception ("There is no way this can be null!");
>>   }
>>
>> Ya. I see that exception "There is no way this can be null!". How does
>> wrappedInstance become null? It is private in the AggregateHashtable class.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Eric
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20110828/411419fb/attachment.html 


More information about the Mono-osx mailing list