AnsweredAssumed Answered

KeyNotFoundException coming from AFSDK

Question asked by SvenBatalla on Aug 13, 2015
Latest reply on Sep 1, 2015 by SvenBatalla

I am currently experiencing an intermittent (but frequent enough to get noticed) exception coming out of the AFSDK.  This exception revolved around enumerations.

 

I have an element template with an attribute of an enumeration type.  When I retrieve the value from AF (using the AFSDK), I must cast the standard "object" response to the AF enumeration type (AFEnumerationValue).  However, when I do this, on the odd occasion, the AFSDK returns the following exception:

 

Unable to cast object of type 'System.Collections.Generic.KeyNotFoundException' to type 'OSIsoft.AF.Asset.AFEnumerationValue'.

 

My code runs on a timer-based interval.  So I just leave it run and the next iteration won't be a problem anymore.  So it seems that occasionally, the AFSDK doesn't know what an enumeration is.  Any thoughts?

Outcomes