“The given key was not present in the dictionary” error

I’m working on re-creating a SmartForms application for a client — which was already in progress when I took over for another engineer — when I bumped into the exception described in the the title. This application was deployed from another environment.

Where’s the problem?

Here’s the exception I saw when attempting to correct an action for calling a SmartObject:

Error: "The given key was not present in the dictionary."
I saw this exception when I attempted to correct an action for calling a SmartObject.

When I checked the SmartObject, I found there was no method to call!

The service method is blank
Well THERE’S your problem!

This application was copied from one environment into this one. It appears as though the stored procedure that powered the object was not created in advance of the K2 deployment.

Whenever deploying K2 objects from one environment to another, it’s important to ensure the data layer of the application (commonly comprised of relational database objects) has been moved in advance.

A quick peek at the SmartObject Services Tester confirms what we found when we looked at the SmartObject in Designer:

The error from the SmartObject Services Tester reads "ServiceObject definition does not contain method."
The error from the SmartObject Services Tester confirms the Service Object data is incomplete: the List() method is missing.

In summary, the error message is associated with a SmartObject with missing ServiceObject data. Although the SmartObject Services Tester throws an error because the method is missing, further investigation revealed the root cause to be a missing stored procedure.

“The given key was not present in the dictionary” error

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s