Ashok_NK

PI AF SDK Connect in .NET 3.5 Version

Discussion created by Ashok_NK on Jun 28, 2013
Latest reply on Jun 28, 2013 by Marcos Vainer Loeff

Hi

 

It seems I am able to connect under .NET 3.5 - but I can't retrieve any attribute values. I can connect and get values in .NET 4.0.

 

My .NET 3.5 code that doesn't work:

 

using (PISystem system = new PISystems()[serverName])
{
    ...
     AFValues afValues = attribute.GetValues(new AFTimeRange(new AFTime(DateTime.Now - TimeSpan.FromDays(7.0)), new AFTime(DateTime.Now)), 800, attribute.DefaultUOM);

 

   ... 
   Result is: AFValue="Unable to open a session on a server.  The user name and password may be incorrect.  abcd11a.pcn.local" UOM=null Timestamp={21/06/2013 3:46:57 PM} IsGood=false 

 

I have also tried specifying credentials:

 

NetworkCredential credential = new NetworkCredential("myuser", "password");
system.Connect(credential);

 

 My .NET 4.0 code that does work:

 

var server = new PIServers()["abcpi"];
server.Connect(new NetworkCredential("myuser", "password"));

 

using (PISystem system = new PISystems().DefaultPISystem)
{

 

AFValues afValues = attribute.GetValues(new AFTimeRange(new AFTime(DateTime.Now - TimeSpan.FromDays(7.0)), new AFTime(DateTime.Now)), 7 * -24 * 6, attribute.DefaultUOM);

 

 

 

How can I get this to work in .NET 3.5? I'm guessing I have to do something equivalent to:
var server = new PIServers()["abcpi"];
server.Connect(new NetworkCredential("myuser", "password")); 

Outcomes