AFCollectiveMember.Connect Method (NetworkCredential)
- Last UpdatedJan 12, 2026
- 3 minute read
- PI System
- AF SDK 3.2.0
- Developer
Connects to the specific server within the AFCollective using the specified
credentials to allow sending and retrieving data.
Namespace: OSIsoft.AF.Collective
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7
Syntax
public void Connect( NetworkCredential credential )
Public Sub Connect ( credential As NetworkCredential ) Dim instance As AFCollectiveMember Dim credential As NetworkCredential instance.Connect(credential)
public: void Connect( NetworkCredential^ credential )
member Connect : credential : NetworkCredential -> unit
Parameters
- credential
- Type: System.NetNetworkCredential
The NetworkCredential to use when connecting to the server.
Events
| Event Type | Reason |
|---|---|
| PISystemConnectChanged | This event will be raised when the connection status for the PISystem changes. |
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | This exception is thrown if connecting to the collective member is disabled because of it Priority setting. |
Remarks
The connection to the specific remote server in the AFCollective is established using the AFCollectiveMember configuration information. When finished with the connection, the PISystem.Disconnect method should be called to free resources used by the connection.
Use the Connect(bool, IWin32Window) method to automatically provide a dialog to prompt for user credentials if the logon fails. Use the Connect(NetworkCredential) method to provide user credentials to be used when connecting to the PISystem.
Examples
// Get the PISystems collection for the current user and default PISystem. PISystem myPISystem = new PISystems().DefaultPISystem; // Set default for all connections to be based upon collective member's priority. AFConnectionInfo.DefaultPreference = AFConnectionPreference.Any; AFCollectiveMember myMember; // Simple connect will use Default Preference. myPISystem.Connect(); myPISystem.Disconnect(); // Check if default PISystem is a Collective. if (myPISystem.Collective != null) { // Connect specifying that Primary is required and display a credential // Connect and display a credential prompt dialog if current user login fails. // Only available in .Net Framework AFSDK // myPISystem.Connect(true, null, AFConnectionPreference.RequirePrimary); // myPISystem.Disconnect(); // Connect specifying that Primary is required and display a credential // Connect and display a credential prompt dialog if current user login fails. // Only available in .Net Framework AFSDK. // Connect to a specific collective member and display a credential // Prompt dialog if current user login fails. // myMember = myPISystem.Collective.Members[0]; // myMember.Connect(true, null); // myPISystem.Disconnect(); try { // Connect to a specific collective member using a specified credential. myMember = myPISystem.Collective.Members[0]; NetworkCredential credential = new NetworkCredential("guest", String.Empty); myMember.Connect(credential); } catch (Exception ex) { // Expected exception since credential needs a valid user name and password. Console.WriteLine(ex.Message); } }