Issue with a property that is a class

Hi all,

I am hitting a wall with this. I have created a class called ValueList with these properties:

IDvalues as Dictionary isHardCoded as Boolean = True ValList as String

I added a constructor with this:

IdValues = New Dictionary

The constructor was added because I discovered that IDValues was nil when the class was instantiated.

Note: this is a Web app, if that changes anything.

Then under Session I added two properties based on my ValueList class. Up to this point everything is (or seems) fine.

In a method I need to get data from a database and add it to the IDValues property. If I create a new ValueList object in the method, all is fine.

But if I reference Session.VLSpecialite in the same method, for example:

Session.VLSpecialite.IDValues.Value(key) = data

Then I get a NilObjectException. Can’t tell which object is null, it can be VLSpecialite or IDValues, Session not being shown in the debugger. . . may be under RunTime, but it’s hard to make it’s way there.

By the way I have set a break point in the class constructor, the code never stopped there ?!?

Does someone has a clue as what’s wrong ?

Thanks a million

You MUST create a “new” Valuelist, at least once… are you doing so?

This came to my mind afterwards. So I VLSpecialite is not instantiated under Session automatically.

I added the Open) event handler to Session with this:

Me.VLSpecialite = New ValueList

It looks like it does the job. I will post back when I test more.

Thanks

That would be a correct statement, and the proper solution :slight_smile:

Well that works fine !!!

Thanks again