I have a windows service which is performing calculations on values obtained from AF attributes.
in this particular test-case we are simply calling GetValue to get the input values for the calculation from the AF attributes.
It works fine on some machines, however on one machine I'm getting exceptions, like this:-
System.ApplicationException: Unable to create the PISDK. PI Data References will not function.
at OSIsoft.AF.Asset.DataReference.PIPointDR.set_Attribute(AFAttribute value)
at OSIsoft.AF.Asset.AFDataReference.Initialize(AFAttribute attribute, AFPlugIn plugIn, Guid id, String configString) in c:\Dev\AF\AF 2.3\Sources\SDK\Asset\AFDataReference.cs:line 315
at OSIsoft.AF.AFPlugIn.CreateDataReferenceInstance(AFObject context, String configString) in c:\Dev\AF\AF 2.3\Sources\SDK\AFPlugIn.cs:line 641
What is really strange, is that each calcuation throws this exception for a period of several 10s of minutes (it varies, upto hours) then springs into life and works fine.
The Service Queues the calculations to the thread pool using "ThreadPool.QueueUserWorkItem" so the GetValue calls are being performed from thread-pool threads. - I have a feeling that may be relevant.
In this simple test we only have a few calculations performed every 30 seconds or so - so my guess is that we are re-using the same thread from the pool.
Oh, and we are using the latest versions of everything ...
Any ideas ?