6 Replies Latest reply on Jan 7, 2013 6:10 AM by eignert

    Retrieve AF SDK error messages

    eignert

      Hi,

       

      first of all I'd like to wish all of the vCampus members a happy new year 2013!

       

      Today I started one of my applications using the latest AF SDK and found the following error message in my console output in Visual Studio:

       
      AFSDK Error: 0 : PIServersGlobal..ctor[]: Error loading PI Server '<PISERVER>' from known servers table: Duplicate ServerID detected in KST
      

       My question is not why this message occurs (I actually really have the PI Server with it's hostname and with an DNS alias in my KST) but how I can retrieve such messages in my appliction b/c I'd like to present all AF SDK error messages to the user.

       

      Thanks a lot for your help,
      Thomas

        • Re: Retrieve AF SDK error messages
          hanyong

          Hi Thomas,

           

          Happy new year to you too 

           

          I am not sure how we can reproduce a situation that will get an error like yours, when is this error printed? Is it when you are getting a reference to the PIServer object from the list of known PIServers collection? or when you are trying to connect to the server?

           

          For most cases, I think error like these can be captured using a Try-Catch. Have you tried doing this? 

            • Re: Retrieve AF SDK error messages
              eignert

              Hi,

               

              to reproduce the "problem" please try the following:

               

              1. You KST should have two entries for the same PI-Server, one for its actual hostname ("pisrv01") and one for its DNS alias ("pisrvalias01").

               

              2. Use the PIServers.GetPIServers()-Method from the AF SDK 2012

               

              Calling the method you will not get an exception (try-catch block would be useless) but the error message above will be printed to the output window of Visual Studio when debugging the application.

                • Re: Retrieve AF SDK error messages
                  hanyong

                  Hi Thomas,

                   

                  You are right, it is outputting the error in the output window and not caught in the application as an exception. Instead of going through the IT to create a DNS alias for this, I hacked an existing entry to point to the IP address of the same server.

                   

                  It seems like AF SDK just sees error, and ignore the server entry. I'll have to check with the AF Developers and see if this is a bug in AF SDK.

                    • Re: Retrieve AF SDK error messages
                      eignert

                      Hello,

                       

                      good to hear you were able to reproduce the issue.

                       

                      It's not a problem that the 2nd server entry is ignored because no configuration like this should exist (happened to me only on my dev machine ;-)). The main question for me is if there are more messages that are outputted like this one and if there is a general way to catch such messages?

                       

                      I would really appreciate it if you would keep me informed with information from your developers!

                        • Re: Retrieve AF SDK error messages
                          David Hearn

                          Having two entries in the KST which reference the same PIServer is not a supported configuration and was actually an issue in the PISDK that allowed it. AFSDK will handle this configuration by ignoring one of the duplicates and reporting the error to any configured .NET TraceListeners. It is not reported as an exception because it is handled by the AFSDK when loading.

                           

                          The debug output window is a .NET TraceListener so you see the message there. AF also ships with a PIMessageLog TraceListener which will output messages to the PIMessageLog and can be enabled in the AFTrace.config (for .NET 3.5) and/or AFTrace4.config (for .NET 4) files located in the “%ProgramData%\OSIsoft\AF” directory. The AFSDK help file for the AFTrace class also has an example for creating your own TraceListener.