Error reading Dictionary "Object reference not set to an instance of an object"

Error reading Dictionary "Object reference not set to an instance of an object"

SRSDS
Advisor Advisor
759 Views
5 Replies
Message 1 of 6

Error reading Dictionary "Object reference not set to an instance of an object"

SRSDS
Advisor
Advisor

Can anyone please explain what is going wrong here.

I'm getting a "NullReferenceException. Object reference not set to an instance of an object" using:

 

    For Each SetEntry As DBDictionaryEntry In SetRootDict
        Dim SetEntryDict As DBDictionary = CType(SetEntry.Value.GetObject(OpenMode.ForRead), DBDictionary)
    Next

I have the same lines letter for letter in a different procedure and referring the same unchanged root dictionary where it works fine.  

 

 

 

 

0 Likes
760 Views
5 Replies
Replies (5)
Message 2 of 6

SRSDS
Advisor
Advisor

I replaced it with an alternative that works.

Dim SetEntryDict As DBDictionary = trans.GetObject(SetRootDict.GetAt(SetEntry.Key), OpenMode.ForRead)

A bit confused why the previous line would work in one location and not another.

0 Likes
Message 3 of 6

jeff
Collaborator
Collaborator

Was one inside a transaction and the other not?

 

If not When TopTransaction is called it might cause that.

 

 

You can also find your answers @ TheSwamp
0 Likes
Message 4 of 6

SRSDS
Advisor
Advisor

Hi Jeff,

 

Both are located inside the top transaction. I think this is relevant but the only difference I see is that the one that didn't work  was being called from an override. Probably not it though, just taking a wild stab.

 

 

 

0 Likes
Message 5 of 6

jeff
Collaborator
Collaborator

Override in a overrule?

 

If in a overrule's check out Stephen Preston's classes on it and if I remember correctly he suggests using OpenCloseTransactions

You can also find your answers @ TheSwamp
Message 6 of 6

SRSDS
Advisor
Advisor

Sorry.. during an overrule. not an override

Yea I've read the classes and watched the videos.

I forgot about the OpenCloseTransactions thing. 

Everything seems to be stable at the moment but I should change that.

 

 

0 Likes