I'm using OSIsoft AF SDK version 4.
After adding the reference and all everything is working fine and visual studio can see the OSISoft namespace and all. But when I try to build I get this error in the output windows and the build fails.
The type or namespace name 'OSISoft' could not be found (are you missing a using directive or an assembly reference?)
Is there any solution to this?
I removed and readded the reference. Opened and closed VS and checked the .Net framework version(actually I tried all available versions). But still, build fails and the same errors persist.
When adding your reference for the AF SDK, you should use the 4.0.0.0 version located in the GAC Assemblies and not pick it directly from the file explorer! This implies that your AF SDK installation is done properly via the PI AF Client installation kit.
More information in the PI AF SDK Documentation here: PI AF SDK Documentation
Deployment of your compiled code: The target client computer for your code must have PI AF Client installed (AF SDK is the only item necessary). Then you just need to copy the compiled executable (and your .dll if any) of your .NET application (do not use a copy of AFSDK.dll from the developement machine.). Then the .dlls from the GAC will be used on the client and everything will work as expected.