FranzK

Access to a BatchView-Control in Processbook from an Processbook-Add-In does not work

Discussion created by FranzK on Jan 17, 2014
Latest reply on Feb 7, 2014 by pingram

Hi all,

 

we want to access a BatchView control (BatchGroup) from an Processbook-Add-In. we also checked the workarround from known-issue 20984OSI8. But it doesn't help in our case.

 

Code snippet:    
                switch (pbDisplay.SelectedSymbols.Item(1).Type) {

                    case (int) PBObjLib.pbSYMBOLTYPE.pbSymbolBGroup:
                        string name = pbDisplay.SelectedSymbols.Item(1).Name;
                        foreach (PBObjLib.Symbol sym in pbDisplay.Symbols)
                            if (sym.Name == name)
                                pbBatchGroup = (BatchGroup) sym;
                        break;

                }

 

We get a crash with the following exception for line pbBatchGroup = (BatchGroup) sym;

 

System.InvalidCastException: "Unable to cast object of type 'PBObjLib.SymbolClass' to type 'OSIsoft.ProcessBook.BatchView.BatchGroup'."

 

Remarks:
1) pbBatchGroup is of type OSIsoft.ProcessBook.BatchView.BatchGroup
2) pbDisplay is of type PBObjLib.Display
3) Iterating the symbols and checking the name against the selected symbol name is a workaround we got from OSI some years ago. the code did work with the processbook we used then. Maybe meanwhile there is another way to access the BatchGroup?
4) Casting pbDisplay.SelectedSymbols.Item(1) to OSIsoft.ProcessBook.BatchView.BatchGroup crashed also with InvalidCastException
5) Access the BatchGroup pbDisplay.Symbols.Item("BatchGroup1") and casting crashed also with InvalidCastException
6) Using type library PIBTPB instead of the assembly OSIsoft.ProcessBook.BatchView.dll crashed also with InvalidCastException

 

Assembly versions:
OSIsoft.PBObjLib.dll: 3.3.2.2076
OSIsoft.ProcessBook.BatchView.dll: 3.1.4.0

Software:
PI ProcessBook 2012 SP2
PI BatchView 2012
Windows 2008 R2
Visual Studio 2010
.NET Runtime 4.0

 

 

 

thank you in advance

 

best regards

 

Franz

 

 

Outcomes