asp.net sample code error

BrianT08725
Participant

asp.net sample code error

Hi, I just downloaded the asp.net c# sample code.

when I try to add a contact using the AddContactSmallForm.aspx,

I got an error stopped at ContactComponent.cs line#963

"data.AppendFormat("<OptInSource>{0}</OptInSource>", optSourceNames[contact.OptInSource]);"

with the error message of "The given key was not present in the dictionary."

 

Just wondering anything I am missing here or any update in the code I missed?

 

Thanks!

 

Liu

3 REPLIES 3
DaveBerard
Moderator

 
Dave Berard
Senior Product Manager, Constant Contact

Hi Dave,

 

Why I don't see anything in your reply? thanks!

Sorry for that Liu, must have been a problem when I posted the reply.

 

The problem looks to be that you are not setting the contact.OptInSource to a valid value.  This is causing the lookup in the optSourceName dictionary to fail and causing your code to throw an exception.

 

I would recommend making sure that you are setting the contact.OptInSource to a valid value.  Leaving it null would also cause the dictionary lookup to fail. 

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

View API documentation, code samples, get your API key.

Visit Page