Problem with loading AFSearchFilterToken

I have a small C# application that searches for some AFEventFframes based on two critera: EventFrames created with a specific template (search on TemplateName) and Eventframes that are InProgress.

 

For most users, it works fine.

 

For one user, he gets this exception:

 

Could not load type 'OSIsoft.AF.Search.AFSearchFilterToken' from assembly 'OSIsoft.AFSDK, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6'.

Unfortunately, I can't be sure whether it is triggering with this code:

AFSearchFilterToken openToken = new AFSearchFilterToken(AFSearchFilter.InProgress, "true");

or this code:

 AppliedSearchTokens.Add(new AFSearchFilterToken(AFSearchFilter.TemplateName, Template.Name));

Intellisense tells me that AFSearchFilter.InProgress was added in version PI AF 2016 (2.8.0), while AFSearchFilter.TemplateName was added in PI AF 2017 (2.9.0).

 

Regardless, the .EXE runs from a network drive, and in that network drive is Osisoft.AFSDK.dll version 2.10.8.440 (this is the version from my developer machine). Installed on his laptop (C:\program files (x86)\pipc\af\publicAssemblies\Osisoft.AFSDK.dll) is version 2.10.8628 - a couple of years older, but still 2.10.


AfSDK.png
It's a 32-bit app. I tried a 64bit version - no change (does the 64 bit version use a 32bit DLL anyway?)

 

I looked at this article to see the search order:

https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order

 

It confuses me a bit, but I assume that it is telling me that for an app run from a network share, it will still look for the local "known" DLL version first, and only look in the current folder later. So I assume it is using his local DLL version.

 

I can try to get his PI version updated, but I would like to understand the issue rather than just do that.

1.) Why is v2.10 not supporting this AFSearchToken?

2.) How do I force the app to use the local DLL version?

 

Thanks!

Andrew

Parents
  • Hi Andrew

     

    When adding the reference to the OSIsoft.AFSDK.dll, make sure the Copy Local setting is True, then you make sure your app always uses the version you intend. The file is located in %pihome%\AF\PublicAssemblies\4.0, so most likely C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\

     

    I've set all my AF SDK-apps to target x64 for many years already, so I can't say much about 32 bit apps. Would recommend going x64 unless you have known restrictions in your user environments preventing 64 bit apps being run.

Reply
  • Hi Andrew

     

    When adding the reference to the OSIsoft.AFSDK.dll, make sure the Copy Local setting is True, then you make sure your app always uses the version you intend. The file is located in %pihome%\AF\PublicAssemblies\4.0, so most likely C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\

     

    I've set all my AF SDK-apps to target x64 for many years already, so I can't say much about 32 bit apps. Would recommend going x64 unless you have known restrictions in your user environments preventing 64 bit apps being run.

Children