22 Replies Latest reply on Jul 26, 2016 6:37 PM by Guilherme Ferreira

    Unable to create the PISDK. PI Data References will not function.

    proberts

      Navigating down AF structure successfully, I've reached the AF object I wish to interrogate.
      It has two attributes I'm interested in:-

       

      1. maxLevel, which is just a value in the attribute
      2. Lvl, which is a pi tag value.

       

      The maxLevel returns the correct value, but the lvl is crashing with the above message, even
      though there is a try-catch immediately surrounding it.

       

      Does anyone have any idea how to correct this?

       

      Failing that, how can I identify the Pi tag name in the Af object - I can then switch to PI SDK
      and get the value myself...

       

      Code snippet  listed below...
      Peter

       

       

       
      Dim maxLvl As OSIsoft.AF.Asset.AFValue
      maxLvl = cell.Attributes("maxLevel").GetValue  ' this works
      
      Try
        Dim lvl As New OSIsoft.AF.Asset.AFValue
        lvl = cell.Attributes("level").GetValue  ' this crashes spectacularly - Pi tag is involved....
      
      Catch ex As Exception
        Debug.Print ex.Message
      End Try
      

       

       

       

       

       

       
        • Re: Unable to create the PISDK. PI Data References will not function.
          proberts

          I'm having difficulty formatting this - I don't know where the scroll bars are coming from.  Please someone fix it for me... it's only a short article...

           

          Ok... I've fixed it... copied out to notepad and pasted it back seemed to do it... an early response would be nice....pretty please....

           

           

            • Re: Unable to create the PISDK. PI Data References will not function.
              MvanderVeeken

              I reformatted your post. I'm not sure what happened You usually get the scrollbars automatically when you paste a code snippet, but you had multiple.

                • Re: Unable to create the PISDK. PI Data References will not function.
                  MvanderVeeken

                  Does the value show in PI System Explorer?

                   

                  What is the exact exception message, and what is the exception type? You are referring to it in your post, but I can't locate it.

                   

                  There are some exceptions that you cannot 'catch' in .NET (StackOverflowException for instance), and there are some exceptions that you can configure not to be 'catched' when Visual Studio is attached as a debugger.

                   

                   

                    • Re: Unable to create the PISDK. PI Data References will not function.
                      cmanhard

                      If you are including a reference to the PISDK within your own code, you must make sure that you use the PISDK supplied interops (OSIsoft.PISDK, OISsoft.PISDKCommon) and not the automatically generated interops. If you are using VS2010 and compiling to .NET 4.0, you must also ensure the "Embed Interop Types" setting to False for the PISDK reference libraries.

                        • Re: Unable to create the PISDK. PI Data References will not function.
                          proberts

                          System.ApplicationException was unhandled by user code

                           

                           Message=Unable to create the PISDK. PI Data References will not function.

                           

                           Source=OSIsoft.AF.Asset.DataReference.PIPoint

                           

                           StackTrace:

                           

                                at OSIsoft.AF.Asset.DataReference.PIBaseDR.Initialize() in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIBaseDR.cs:line 423

                           

                                at OSIsoft.AF.Asset.DataReference.PIBaseDR.set_Attribute(AFAttribute value) in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIBaseDR.cs:line 255

                           

                                at OSIsoft.AF.Asset.DataReference.PIPointDR.set_Attribute(AFAttribute value) in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIPointDR.cs:line 429

                           

                                at OSIsoft.AF.Asset.AFDataReference.Initialize(AFAttribute attribute, AFPlugIn plugIn, Guid id, String configString) in c:\Builds\AF\AF 2.4\Sources\SDK\Asset\AFDataReference.cs:line 382

                           

                                at OSIsoft.AF.AFPlugIn.CreateDataReferenceInstance(AFObject context, String configString) in c:\Builds\AF\AF 2.4\Sources\SDK\AFPlugIn.cs:line 1153

                           

                           InnerException:

                            • Re: Unable to create the PISDK. PI Data References will not function.
                              proberts

                              Thanks for the formatting fix.... I've just posted a copy of the exception.  I'll now check for PI add-ins, etc, though up to now I haven't had a problem.

                               

                              BTW, the value shows up in PI system explorer - I'm using the sinusoid tag.

                               

                               

                                • Re: Unable to create the PISDK. PI Data References will not function.
                                  proberts

                                  I am using VS2010 and compiling to .net 4.0, , so where do I ensure that the "Embed Interop Types" is set to False for the PISDK reference libraries ??

                                    • Re: Unable to create the PISDK. PI Data References will not function.
                                      cmanhard

                                      If using C#, in the Solution Exploer, under References, right click on the Properties menu item for the refrences OSIsoft.PISDK, OSIsoft.PISDKCommon and OSIsoft.PITimeServer assemblies.  You will find a property "Embed Interop Types".  Set it to False.

                                       

                                      If using VB.NET, first, make sure the Properties window is opened (View/Properties Window).  Then in the Solution Explorer, right click on the Properties menu for the Project.  From their, navigate to the References tab.  Click on each of the PISDK assembly references, then set the "Embed Interop Types" parameter to false in the Properties window.

                                       

                                      In both C# and VB.NET, you must add a reference to the PISDK supplied interop under PIPC\PISDK\PublicAssemblies, and NOT add via COM tab in the Add Reference dialog.

                                        • Re: Unable to create the PISDK. PI Data References will not function.
                                          proberts

                                          OK, I've complied with all the above, and it's still crashing... latest report: -

                                           

                                          System.ApplicationException was unhandled by user code

                                           

                                           Message=Unable to create the PISDK. PI Data References will not function.

                                           

                                           Source=OSIsoft.AF.Asset.DataReference.PIPoint

                                           

                                           StackTrace:

                                           

                                                at OSIsoft.AF.Asset.DataReference.PIBaseDR.Initialize() in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIBaseDR.cs:line 423

                                           

                                                at OSIsoft.AF.Asset.DataReference.PIBaseDR.set_Attribute(AFAttribute value) in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIBaseDR.cs:line 255

                                           

                                                at OSIsoft.AF.Asset.DataReference.PIPointDR.set_Attribute(AFAttribute value) in c:\Builds\AF\AF 2.4\Sources\PlugIns\DataReferences\AFDRpi\PIPointDR.cs:line 429

                                           

                                                at OSIsoft.AF.Asset.AFDataReference.Initialize(AFAttribute attribute, AFPlugIn plugIn, Guid id, String configString) in c:\Builds\AF\AF 2.4\Sources\SDK\Asset\AFDataReference.cs:line 382

                                           

                                                at OSIsoft.AF.AFPlugIn.CreateDataReferenceInstance(AFObject context, String configString) in c:\Builds\AF\AF 2.4\Sources\SDK\AFPlugIn.cs:line 1153

                                           

                                           InnerException:

                                            • Re: Unable to create the PISDK. PI Data References will not function.
                                              proberts

                                              ok.  I've discovered that the element attribute ConfigString contains the pi server name and the pi tag name embedded in it along with some other detail that look like GUID and versioning stuff.  so I'm pulling the tag and server from this attribute then calling PISK for the value (and timestamp).

                                               

                                              I'm surpised, actually, that I didn't find the tag detail in the attribute to do with data reference, because that's where PISystemExplorer displays it...

                                               

                                              This works, but it is long winded.

                                                • Re: Unable to create the PISDK. PI Data References will not function.
                                                  MvanderVeeken

                                                  That's some workaround! But you also have to make sure you 'copy' all the other settings from the PIPointDataReference.

                                                   

                                                  That being said: I would really suggest we keep looking for an answer to your original problem. This is a huge 'hack' circumventing a lot of build in functionality.

                                                   

                                                  Have you tried creating a simple solution from scratch, following Chris' instructions on how to reference the PISDK assemblies? I you can make that work, you can go from there.

                                                    • Re: Unable to create the PISDK. PI Data References will not function.
                                                      cmanhard

                                                      Agree with Michael.  This is issue with the PISDK is well known.  If you load multiple versions of the PISDK interop, the 2nd attempt to create the PISDK class will fail.  I suggest you look in all other assemblies that you are including to make sure you do not have these references there.  You should also look for references to PISDK 1.3 Type Library in your reference list.  These also should be removed.  Are you using any of the PI SDK Controls - these too need to be added with the OSI provided interops and with "Embed Interop Types" set to false.

                                                        • Re: Unable to create the PISDK. PI Data References will not function.
                                                          proberts

                                                          I was compiling for a console application, so there are no PI SDK controls... I've also previously removed all references to PISK 1.3 Type libraries... and followed the instructions above.  If I get time I'll start again with a new project and test it all again...

                                                            • Re: Unable to create the PISDK. PI Data References will not function.
                                                              proberts

                                                              I've tried a few more 'tricks' to try and isolate the real issue, based on the discussion above highlighting the interaction between versions of PI SDK etc. the code I was using had already established a link to a PI server using PI SDK, and then established a link to an AF server (a different server).  I was wondering if the two applications were incompatible, so I removed all the PI SDK calls and libraries, leaving only the PI AF modules.  Now I have an error that is caught by the trap, so I have made progress...  does this mean that I can't put PI SDK libraries and PI AF libraries in the same application??

                                                               

                                                               

                                                               

                                                              BTW, there is not a defined PI tag in the element I'm examining at the moment - which may have been the cause of the original untrappable error.  Now I get the error caught in the trap that the tag can't be found (or words to that effect).

                                                                • Re: Unable to create the PISDK. PI Data References will not function.
                                                                  cmanhard

                                                                  PI SDK and AF SDK can coexist within the same application.  However, all uses of PI SDK within must reference the same PI SDK interop – this includes other assemblies you like in.  The correct interop to use is the one that is found in be referenced in Program Files (x86)\PIPC\PISDK\PublicAssemblies.  This is the one that AF uses.  There are several ways this could break, in decreasing order of probability:

                                                                   

                                                                  1) Using .NET 4, there is a new "Embed Interop" option for COM libraries that is automatically selected and is incompatible with the existing AF reference to PI SDK.  You can fix by either turning this option off (as detailed previously), or, changing your project to produce a .NET 3.5 application.

                                                                   

                                                                  2) If you reference the COM type libraries directly, rather than the provided interops.  This typically would be seen as having PISDK references in your application/library that have “Typelib” in their name.

                                                                   

                                                                  3) If your original project was built against an earlier version of the PI SDK and somehow the policy file(s) were removed which auto-upgrades to the latest assembly.  (If you have PISDK 1.4 installed, I would expect to see policy files in the GAC  (typically c:\windows\Assembly for PISDK 1.2 and PISDK 1.3)

                                                                   

                                                                  4)  You load the PISDK via late binding and not direct references to the supplied interops assemblies.

                                                                   

                                                                  The tag not found error would be expected if the tag is not found, however, it is not the reason for the "Unable to created PISDK" error.

                                                                   

                                                                  You may be able to detect where in your libraries the other reference is made by flipping the order of access - using the AF reference first, followed by your library reference

                                                                    • Re: Unable to create the PISDK. PI Data References will not function.
                                                                      chandotnet

                                                                      Sorry to bump this thread up but we still have a problem !

                                                                       

                                                                      Our project references:

                                                                       

                                                                      C:\Program Files (x86)\PIPC\AF\PublicAssemblies\OSIsoft.AFSDK.dll
                                                                      | Assembly Version=2.0.0.0
                                                                      | Copy local=False
                                                                      | Embed Interop=False
                                                                      | Specific Version=False

                                                                       

                                                                      C:\Program Files (x86)\PIPC\PISDK\PublicAssemblies\OSIsoft.PISDK.dll
                                                                      | Assembly Version=1.4.0.0
                                                                      | Copy local=False
                                                                      | Embed Interop=False
                                                                      | Specific Version=False

                                                                       

                                                                      C:\Program Files (x86)\PIPC\PISDK\PublicAssemblies\OSIsoft.PISDKCommon.dll
                                                                      | Assembly Version=1.4.0.0
                                                                      | Copy local=False
                                                                      | Embed Interop=False
                                                                      | Specific Version=False  

                                                                       

                                                                      C:\Program Files (x86)\PIPC\PISDK\PublicAssemblies\OSIsoft.PITimeServer.dll
                                                                      | Assembly Version=1.4.0.0
                                                                      | Copy local=False
                                                                      | Embed Interop=False
                                                                      | Specific Version=False

                                                                       

                                                                      And somewhere in our code we are querying AF like this:

                                                                       

                                                                       

                                                                       
                                                                      var afValue = gaz.Attributes["GazMetroDay"].GetValue(new AFTime(startTime.AddDays(1).ToString("yyyy-MM-dd 08:27")));
                                                                      

                                                                      And this will throw a FileLoadException in CreateInstance in AFPlugIn.cs:

                                                                       

                                                                      Could not load file or assembly 'OSIsoft.PISDK, Version=1.3.0.0, Culture=neutral, PublicKeyToken=c3309f0734ba2805' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

                                                                       

                                                                      That's clear that the plug in want the version 1.3.0.0 but we are referencing 1.4.0.0 ... the question is why 1.3.0.0

                                                                       

                                                                      AF was updated to 2010 R3 by OSIsoft it self.

                                                                       

                                                                      We have tried our program on different machine but still got the error.

                                                                       

                                                                      Versions in PI System Explorer about dialog:

                                                                       

                                                                      5305.PISysVersions.PNG

                                                                       

                                                                       

                                                                       

                                                                      I suspect a problem with AF data references assemblies but I don't have enough knowledge to debug.

                                                                       

                                                                      So far I did a select on AF SQL database PIFD.Assembly2 and here what we have:

                                                                       

                                                                       

                                                                       
                                                                      name     version
                                                                      NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c     2.0.0.0
                                                                      Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null     1.0.0.0
                                                                      OSIsoft.AF.Time.TimeRule.Periodic, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4431
                                                                      OSIsoft.AF.Analysis.AnalysisRule.Imbalance, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4431
                                                                      OSIsoft.AF.Analysis.AnalysisRule.PerformanceEquation, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Notification.DeliveryChannel.WebService, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Analysis.AnalysisRule.Condition, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Notification.DeliveryChannel.Email, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Notification.DeliveryChannel.OCS, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.PI.Net     1.0.0.1
                                                                      OSIsoft.PI.Net     1.0.0.1
                                                                      OSIsoft.AF.Asset.DataReference.IntermediateVariable, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Asset.DataReference.TableLookup, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4431
                                                                      OSIsoft.AF.Analysis.AnalysisRule.SQC, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      SMART.AF.DataReference, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null     1.0.0.0
                                                                      OSIsoft.PI.Configuration     1.0.0.0
                                                                      OSIsoft.PI.Configuration     1.0.0.0
                                                                      OSIsoft.AF.Analysis.AnalysisRule.Sequential, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Asset.DataReference.PIPoint, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4431
                                                                      OSIsoft.AF.Asset.DataReference.PIPoint, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4132 Internal 07-Dec-2011
                                                                      OSIsoft.AF.Time.TimeRule.Event, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      OSIsoft.AF.Asset.DataReference.Formula, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6     2.4.0.4431
                                                                      OSIsoft.AF.Time.TimeRule.OR, Version=1.0.777.0, Culture=neutral, PublicKeyToken=6238be57836698e6     1.2.1205.6
                                                                      

                                                                       

                                                                       

                                                                      You can see that we have 2 - two - dos - deux  OSIsoft.AF.Asset.DataReference.PIPoint and one is an Internal 07-Dec-2011. I suspect this DLL to be used instead of the good one ?

                                                                       

                                                                      There is a way to uninstall the 07-Dec-2011 assembly ? just delete the row in SQL ?

                                                                       

                                                                      Thank you very much for your help.

                                                                       

                                                                      Sébastien

                                                                       

                                                                       

                                                                        • Re: Unable to create the PISDK. PI Data References will not function.
                                                                          mhamel

                                                                          @Sebastien: It looks like two versions of the PI Point Data Reference were installed. This should not have happened. The record will have to be rebuilt in the PIFD database. I would recommend you to contact our Techsupport team for this actually, because they would be better equipped to help you troubleshoot issues like these over the phone and through remote sessions etc.

                                                                            • Re: Unable to create the PISDK. PI Data References will not function.
                                                                              tmccune

                                                                              I have the same issue as described by Sebastion.   I have version 2.4.0.4431 of OSIsoft.AFSDK and my Visual Studio is complaining that it cant find 1.3.0.0 versions of OSISOFT.PISDK, OSISOFT.PISDKCOMMON, OSISOFT.PITIMESERVER.   I have the 1.4.0.416 versions of the PI* dlls.   How can I get the version compatibility back in sync?

                                                                                • Re: Unable to create the PISDK. PI Data References will not function.

                                                                                  Hello Todd,

                                                                                   

                                                                                  I understand you are facing an issue with PI SDK. Your project is referencing PI SDK 1.3 (major version) but you do have PI SDK 1.4.0.416 installed. I see 2 options addressing this version mismatch.

                                                                                   

                                                                                  1. Remove the PI SDK 1.3.0 versions from your Visual Studio project and add references to the installed library versions.

                                                                                   

                                                                                  2. Downgrade PI SDK to a version before 1.4.0 (i.e. 1.3.8.388). To achieve this you would need to remove PI SDK through "Add or Remove Programs" ("Programs and Features").

                                                                                   

                                                                                  I recommend option # 1 unless you have the requirement to built against PI SDK 1.3

                                              • Re: Unable to create the PISDK. PI Data References will not function.
                                                MaxStrueverWipro

                                                I am getting this error in just regular old ProcessBook when trying to display an AF Attribute value),

                                                not a custom app,

                                                So I am unable to change the "embed interop types", any suggestions?