11 Replies Latest reply on Jul 1, 2016 2:39 PM by Chris_Hawkins

    PI SDK problem (of my own making!)

    Chris_Hawkins

      I attach screenshots from two versions of the same routine. IOne written in VB.NET (which works) and one writtemn in C# (which doesn't work). While recognising the problem lies with my limited grasp of C# I'd appreciate guidance as to waht I'm doing wrong.

      The offending lines in C# contain DirectCast (which I don't think is available in C#) if the PIPoint is a digital state and the PIPoint piVal.Value which I wish to cast as a string

       

           myTemp = Convert.ToString(piVal.TimeStamp.LocalDate) + delimiter + " " + DirectCast(piVal.Value, DigitalState).Name;

       

           myTemp = Convert.ToString(piVal.TimeStamp.LocalDate) + delimiter + " " + piVal.Value.ToString();

      Note that I founfd the construct piVal.Value.ToString() in a PI SDK coding example on the Web. Even if I truncate to use Convert.ToString(piVal.Value) or just piVal.piValue it still doesn't work

      The error messsages are shown in screeshot 3

       

      VB.JPG

      The above in VB works

      The below in C# doesn't work

      Csharp.JPG

       

      with error messages

       

      errors.JPG