9 Replies Latest reply on Jul 26, 2013 11:18 AM by Marcos Vainer Loeff Branched to a new discussion.

    Problems with Pbobjlib.tlb registration & use.


      I am developing a C# application that essentially uses Pbobjlib.tlb to create a PI ProcessBook application instance, and then do some stuff (load displays etc).  I am having a few little problems, and am trying to diangose / resolve them.  This is a spin-off from this thread: http://vcampus.osisoft.com/discussion_hall/add_in_microsoft_development/f/11/p/4197/22324.aspx


      As noted in that thread, I was having problems with macro protection not firing when application.displays[].open was called.  It was suggested that I instead try using the "Global" class application object, instead of the Application class direct.  When I tried this, I got an error that the class was not registered.  I have been trying to resolve this, and this thread is to get help on the problems I have found.


      Firstly, I am using ProcessBook  Here is the system info:


      PI ProcessBook
          COMCTL32.dll    6.1.7600.16385 6.10.7601.17514 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\
          MFC80.DLL       8.00.50727.4053 8.0.50727.4053 C:\Windows\WinSxS\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.4053_none_cbf21254470d8752\
          ModContextSupport.ocx 3.02       C:\Program Files\PIPC\Procbook\ModuleContext\
          ModuleContext.dll 3.02       C:\Program Files\PIPC\Procbook\ModuleContext\
          MSO9.DLL        9.0.3610    C:\Program Files\Microsoft Office\Office\
          MSVBVM60.DLL    6.00.9815     C:\Windows\system32\
          MSVCR80.dll     8.00.50727.6195 8.0.50727.6195 C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_d09154e044272b9a\
          msvcrt.dll      7.0.7601.17744 7.0.7601.17744 C:\Windows\system32\
          Pblib32.dll       C:\Program Files\PIPC\Procbook\
          pisdk.dll     C:\Program Files\PIPC\PISDK\
          PISDKCommon.dll     C:\Program Files\PIPC\PISDK\
          PISDKDlg.dll    1.06.0365     C:\Program Files\PIPC\PISDK\
          PITimeServer.dll     C:\Program Files\PIPC\LIBRARY\
          Plot.dll       C:\Program Files\PIPC\Procbook\
          Prims32.dll       C:\Program Files\PIPC\Procbook\
          Procbook.exe       C:\Program Files\PIPC\Procbook\
          SQC.DLL       C:\Program Files\PIPC\Procbook\
          svg_addin.dll   3.02       C:\Program Files\PIPC\Procbook\SVG_addin\
          Toolbox.dll       C:\Program Files\PIPC\Procbook\
          Trend32.dll       C:\Program Files\PIPC\Procbook\
          VBE6.DLL        6.05.1054     C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA6\
          xyplot.dll       C:\Program Files\PIPC\Procbook\
      Copyright © 1993 - 2010 OSIsoft, LLC


      In my application, I am adding a reference to the Interop.PBObjLib (PI-ProcessBook Type Library, version 3.1 & 3.2, c:\Program Files\PIPC\Procbook\Pbobjlib.tlb) I am assuming that it is a self-registering library.


      Anyway, when I add a reference to this library, it adds OK to my application.  I can run it, and it works properly (creating processbook instances etc), and the only real problems is that macros execute when I programatically open a display.  IN trying to solve that, as per the advice given, when I try to make the following declaration:

                  PBObjLib.Global oPiObject = new PBObjLib.Global();
                  m_oPIApp = oPiObject.Application;

       It compiles fine, but I get a runtime error that:


      Retrieving the COM class factory for component with CLSID {B97046B1-577C-11D0-BACC-00AA00BFB45A} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).


      I decided to try something different.  I had been running my Visual C# IDE as a normal user.  I tried to instead run it as an administrator, and got a whole lot of weird errors when I restarted the IDE:


      Cannot get the file path for type library "0cf87d80-9e07-11cf-840c-00aa00422a4a" version 3.2. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) 


      The type or namespace name 'PBObjLib' could not be found (are you missing a using directive or an assembly reference?) 


      I therefore tried to remove the existing reference, and add a new one.  Trying to add a reference to library 3.2, I get:


      A reference to "PI-Processbook Type Library" could not be created.


      Trying to add a reference to library 3.1, I get:


      A reference to "PI-Processbook Type Library" could not be added. Could not register the ActiveX type library 'C:\Program FIles\PIPC\Procbook\pbobjlib.tlb'.


      So... Thoroughly confused.  Why can I register and use the library when the IDE is as a normal user, but not when started as an administrator?


      Note:  I have uninstalled and reinstalled, including cleaning-out old unused references in the registry.




      Any suggestions appreciated!

        • Re: Problems with Pbobjlib.tlb registration & use.

          Project CPU set to x86?

            • Re: Problems with Pbobjlib.tlb registration & use.

              Yes.  I am actually using the Express Edition, so can't set it to anything but x86.

                • Re: Problems with Pbobjlib.tlb registration & use.

                  @Andrew: Why aren't you making use of OSIsoft.PBObjLib.dll? It looks like you are using another interop library generated after adding a reference to pbobjlib.tlb.


                  I suspect many of your problems are starting from there.


                  Can you try to use the OSIsoft.PBObjLib.dll assembly in your C# project?

                    • Re: Problems with Pbobjlib.tlb registration & use.

                      Osisoft.PBOBLlib.dll is a hidden file in my install.  Nevertheless, I can add it as a reference, but still get the error described above.


                      Edit:  There is a copy that is not hidden under \Program Files\PIPC\Processbook\Public Assemblies\ but that still gives the error as well.

                        • Re: Problems with Pbobjlib.tlb registration & use.

                          @Andrew: You are right, OSIsoft.PBObjLib.dll is hidden and protected by the system as it is registered againtst the GAC. The version I have pointed out under ..\Program Files (x86)\PIPC\ProcessBook\Public Assemblies is the same version that you can add a reference to your project. During the initialization process of your application or add-in, the assembly location will be resolved automatically for you and would normally find them under C:\Windows\Assembly (.NET Framework 2, 3 and 3.5) or C:\Windows\Microsoft.NET (.NET Framework 4+).


                          I will continue to investigate your problem.

                            • Re: Problems with Pbobjlib.tlb registration & use.

                              Thanks.  Note that the original version  I was using was the one that is automatically registered when PI ProcessBook is installed (i.e under C#, add reference, listed under the "COM" tab.)  I do note that some objects in the library work fine (the "Application" object), but others don't (the Global.Application object).

                                • Re: Problems with Pbobjlib.tlb registration & use.
                                  Marcos Vainer Loeff

                                  Hello Andrew,


                                  You are receiving the error below because global is an interface and not a class, therefore, it cannot be instantiated.


                                  Normally, you would use the global Application on your VBA Editor of PI ProcessBook . Below you can find an example:



                                  Sub PrintAppName()
                                      Dim N as String
                                      N = Application.Name
                                      Debug.Print N
                                  End Sub



                                   Notice that we aren't creating a "new" anything.  We are just using the global variable "Application" that PB creates.


                                   In a C# application, you should create the application object in a regular way, since you won’t be able to use the global application.



                                  PBObjLib.Application myApplication = new PBObjLib.Application();



                                  Hope this helps,

                                    • Re: Problems with Pbobjlib.tlb registration & use.

                                      OK - thanks.  


                                      This actually stemmed from this thread:




                                      As you can see, I am simply trying to create a ProcessBook application via COM, and then load a display, without the Macros firing.  I couldn't get this to work, and it was suggested that I use the "Global" object instead.  I'm really not sure what I shoudl be doing here.....  


                                      In a nutshell, I want to:


                                      1.) Create a PBObjLib.Application Object


                                      2.) Use PBObjLib.Application.Displays.Open(sDisplayFullPath, true);  to open a display; BUT


                                      3.) Prevent macros running when the display is opened.  


                                      If the application is created with MacroProtectionLevel=6, then the macros still run.  (Note:  If the display is opened programatically using Display.Open, the macros run.  If I manually (i.e. with the mouse) activate the ProcessBook instance I have created manually and manually load the same display, the macros don't run.