IMD SolutionComputing LibraryShop main store

Troubleshooting

Why an AF SDK application cannot connect on a client machine

Edge computing and IIoT Published 7 min read

Short answer

The installer copying only OSIsoft.AFSDK.dll does not deploy the AF SDK; the target machine needs the AF Client package as a prerequisite, with the AF SDK assemblies component selected. Add the separate PI SDK installer when the application targets .NET 3.5. Install that client package on the failing machine and the same application connects; then separate loader failures from connection and data failures by the exception the first AF call throws.

On this page
  1. Why does the application connect on the build machine but not on a client machine?
  2. Can I just copy OSIsoft.AFSDK.dll into the application installer?
  3. Which AF Client components does a runtime-only client machine need?
  4. Does a .NET 3.5 target change the client prerequisite?
  5. How do I tell an assembly-loading failure from a connection failure?
  6. What should I check when the client is installed but the connection still fails?
  7. How do I build the installer so every target machine has the prerequisites?
  8. Questions asked

An application that ships only the core assembly does not deploy the AF SDK: OSIsoft.AFSDK.dll is one referenced file, while the runtime the loader needs is the AF Client package, and a machine without that package fails on the first call into the SDK. Installing the PI client on the same machine makes the identical binary connect, and that difference is the diagnosis. Make the AF Client package an explicit prerequisite with the AF SDK assemblies component selected, add the separate PI SDK installer only when the application targets .NET 3.5, then separate loader failures from connection and data failures by the exception the first call throws. Deployment to a clean runtime machine is this article's subject; the C# connection path from code is covered in PI AF SDK: the native path from a C# application to PI.

Why does the application connect on the build machine but not on a client machine? #

Because the build machine already has the AF Client installed and the client machine does not: your installer carries one referenced assembly, OSIsoft.AFSDK.dll, while the loader needs the whole SDK runtime, and only the AF Client package puts those assemblies where .NET resolves them.

The comparison that proves it takes two machines and one installer. Run the identical binary on the build machine and on a clean target: the build machine connects, the clean target fails, and the only difference between them is the presence of the client runtime. That one test rules out the application code, the PI server and the network together, and it moves the fault to deployment. Treat every step that follows as completing the target machine's prerequisite list, not as debugging the program.

Can I just copy OSIsoft.AFSDK.dll into the application installer? #

No: copying the core assembly is not a supported deployment, because the AF SDK needs additional assemblies beyond the one your project references, so an installer that ships a single DLL can complete its own install while leaving the machine unable to load the SDK at run time.

Worked example: the installer's file list contains exactly 1 SDK file, the assembly the project referenced. At run time the loader resolves that file, reads its dependency list and asks for each supporting assembly next, so the deployment must satisfy 1 carried file plus the supporting assemblies the loader requests. With 1 file carried and the loader asking for at least 1 assembly more, the machine is short by at least that 1 assembly, and the shortfall surfaces as a FileNotFoundException naming the missing assembly before any packet reaches the PI server. AF Client closes the gap by installing the SDK assemblies where the .NET loader resolves them machine-wide, which a private DLL beside the executable cannot do.

Which AF Client components does a runtime-only client machine need? #

Select the AF SDK assemblies component and clear the user-interface features the machine does not need: PI System Explorer, PI Builder and the management plug-ins are optional selections in the same installer, and a typical installation installs all features at once.

Any installation that includes the SDK assemblies satisfies the application, so a full client install also works; the assemblies-only selection exists to keep management tools off endpoints that serve one application. Use the broader selection where the maintenance workflow genuinely runs those tools on the same machine.

AF Client installer component Runtime-only endpoint Administrator workstation
AF SDK assemblies Select, this is the runtime the application loads Select
PI System Explorer Clear Select when staff maintain AF hierarchies here
PI Builder Clear Select for bulk structure edits
Management plug-ins Clear Select as the maintenance workflow requires

Does a .NET 3.5 target change the client prerequisite? #

Yes: the AF Client .NET 3.5 components require PI SDK as well, and PI SDK arrives by its own separate installer, so selecting the legacy component inside AF Client does not by itself complete that machine's prerequisite list.

The dependency is narrow. Organizations typically need the .NET 3.5 client components when they run legacy PI Notifications from the 2012x releases or earlier, or when custom code was built against that stack; a project targeting .NET Framework 4.0 or a later framework builds against the current assemblies, so the PI SDK step drops out of the plan. On the legacy branch, the AF Client set-up program checks for the presence of PI SDK and installs or upgrades it as necessary, which means the installer enforces the prerequisite for you, but the PI SDK kit still has to travel with your distribution. Decision: read the target framework from the build configuration first, and let it, not the operating system image, pick the component.

How do I tell an assembly-loading failure from a connection failure? #

Read the exception and every inner exception: a loader failure such as FileNotFoundException or a type-initialization error at the first AF call happens before any network traffic, while a connection or authentication failure proves the SDK loaded and names the server step that failed.

Match the failure to one branch and follow only that branch:

  • Exception or type-initialization failure on the very first call into the SDK, so the client runtime or framework component is wrong and the prerequisite steps need redoing.
  • Failure while enumerating or opening a PI System, so the SDK loaded and the server name, name resolution and network route need checking.
  • Authentication or access-denied result, so the Windows identity the process actually runs under needs checking.
  • Failure when opening the AF database, so the database name and that identity's read rights need checking.
  • Failure on one element, attribute or value, so deployment is proven and the reference or mapping is wrong.
  • Data returns but the display stays empty, so the fault is in the application's binding, not the client deployment.

The same split appears in three lines of code, and the line that throws is the branch you follow:

PISystems systems = new PISystems();        // load and initialize the SDK
PISystem system = systems.DefaultPISystem;  // select the server
system.Connect();                           // connect and authenticate

What should I check when the client is installed but the connection still fails? #

Work the path in order, server name and resolution, the network route, the identity the process runs under, then the AF database and one known data item, and change one layer at a time so the next exception tells you which layer moved.

Read the server target from the application's configuration and compare it with the intended endpoint before anything else: an installer that captured a development server name, for example a host named PI-ARCHIVE-01 on the build network, fails identically on every machine it reaches. Confirm name resolution for that exact name from the client machine, then the port and route per the server's documented connection requirements.

AF SDK connection preferences are set through PI System Explorer, so on a runtime-only machine where you cleared that feature, set and verify them from an administrator workstation instead of adding the tool back to the endpoint.

Then follow the identity. An interactive test that connects while the deployed context fails points at the account: reachability follows the Windows identity, the same mechanism that decides which archive a client sees in When PI Vision connects to only one PI Data Archive. Keep the application configuration unchanged across these retests so each result stays comparable.

Finish with data, not with the connection message: open the intended AF database, read one known element attribute and check the value and timestamp against the server. Decision: when that one item returns its expected value, deployment, connection and rights are all proven, and anything still wrong lives inside the application.

How do I build the installer so every target machine has the prerequisites? #

Make the AF Client package an explicit prerequisite of the deployment, download the install kit from the vendor's support portal, record the target framework and the component selection in the build notes, and retest on a machine that carries none of the developer tools.

  1. Record the application's target framework from its build configuration.
  2. Add AF Client to the prerequisite plan with the AF SDK assemblies component selected, and clear PI System Explorer, PI Builder and the management plug-ins where the endpoint does not need them.
  3. On the .NET 3.5 branch, add the separate PI SDK installer to the same plan.
  4. Obtain the kits through the manufacturer or an authorized distributor and follow their documented installation procedure.
  5. Prepare a representative target computer with the selected runtime and client prerequisites installed through the intended distribution process, and run the application there before rollout.

The decision, case by case. A machine that throws on the first AF call gets the AF Client package with the assemblies component, plus PI SDK only when the target is .NET 3.5. A machine with the client installed that fails to connect gets name resolution, then identity, then database and rights checks. A machine that loads, connects and returns a known value but shows nothing has an application fault, and no further client installation will change it.

Questions asked

Do I have to rebuild or change the application after installing the AF Client?

No. The compiled binary stays exactly as it is; only the machine's client runtime changes. Reference the same core assembly the project was built against and expect the installed client package to supply the matching runtime. If a type load error appears after a client version upgrade rather than a clean install, check that the installed AF SDK version still matches the one the application was compiled against.

Is PI SDK the same thing as AF SDK?

No. PI SDK is the earlier client library for PI Data Archive access; AF SDK is the .NET library for the AF database and the interface current applications build against. They share a machine only because the AF Client .NET 3.5 components depend on PI SDK, which is why the separate PI SDK installer enters the plan on that branch and nowhere else.

Why does a manual test connect while the same application fails as a scheduled task or service?

Because the two runs use different Windows identities, and access is granted per identity on the server. Run the service under the account you tested with, or map the service account the same way the interactive account is mapped, and compare the identity from the failing run before changing any server-side setting.

How do I confirm which .NET Framework version my application targets?

Read it from the build configuration: the target framework setting in the application project is the value that decides the AF Client component selection. For an application inherited without sources, the runtime the executable loads at start-up identifies the framework family, and the supplier or the build notes give the exact target.

Keep reading

  • How-to

    Deploying Edge Data Store in Docker on a controller PC

    Run Edge Data Store as a Docker container on the controller-class edge PC and let its OPC UA adapter ingest the local server over localhost. Define egress targets, buffering and forwarding schedules in the JSON configuration, size the buffer from tag count, scan rate and outage target—50 tags at 1 event/s across an 8-hour outage is about 288 MB—and sign off only after a live pulled-cable test.

    Edge computing and IIoT

  • Troubleshooting

    Fix ECONNREFUSED when Node-RED connects to a remote SQL database

    ECONNREFUSED 127.0.0.1:3306 means the MySQL node dialed loopback on the machine running Node-RED, so the database computer was never contacted. Put the database computer's LAN address in the node's Host field, confirm MariaDB listens on that interface with TCP 3306 open, and create the account with the edge device's address as its host part.

    Edge computing and IIoT

  • Explainer

    PI AF SDK: the native path from a C# application to PI

    No driver joins two OPC UA clients, so KEPServerEX needs no new driver for this. Read PI Data Archive and PI Asset Framework from C# through PI AF SDK, which needs the server-side PSA license. Any new values must flow through a real OPC UA server endpoint that a licensed PI OPC UA interface or connector collects from.

    Edge computing and IIoT