akenyon

PISDK Access Violation

Discussion created by akenyon on Oct 14, 2013
Latest reply on Oct 15, 2013 by akenyon

Hi,

 

We're developing an application that reads data from an older SQL server and back fills the data in a PI collective. The application begins to write data to PI before crashing with an Access Violation Exception thrown by the PISDK. The exception seems to occur randomly; it doesn't seem to occur at any specific point or at any specific time. Originally we thought the issue occurred because we were using two background threads to concurrently write points to our PI Collective, after changing the application to write point by point the exception still occurs. Is there a way to avoid this issue? We're using the PISDK v1.4.2.445 with our application, we're considering rewriting using the AFSDK, obviously our concern is that the error still occurs after we rewrite the application.

 

 

 

Here's the last bit of the Call Stack:

 

ntdll.dll77466d20

 

piskd.dll!CComClassFactorySingletonPerThread<CPISDK>::RemoveThread()

 

pisdk.dll!CComObjSingletonPerThread<CPISDK>::Release()

 

pisdk.dll!IsPISDKGood()

 

pisdk.dll!CComClassFactorySingletonPerThread<CPISDK>::CreateInstance()

 

 

 

The function writing data to PI

 
public static in InsertValues(string PISystem, string tag, List<PIValue> data)
{
     try
     {
          PISDK.Server srv;
          PISDK.PISDK = new PISDK.PISDK();
          Srv = Pisdk.Servers[PISystem};
          srv.Open()

          var pValues = new PISDK.PIValues();
          pValues.ReadOnly = false;
          
          foreach(var item in data)
          {
               pValues.Add(item.TimeStamp, item.Value, null);
          }
          pValues.ReadOnly = true;
          Srv.PIPoints[tag].Data.UpdateValues(pValues, DataMergeConstants.dmReplaceDuplicates);
          Srv.Close();
          return 0;
     }
     catch (Exception ex)
     {
          return -1;
     }
}

 

Outcomes