For .Net Add-Ins, you should be using regasm.exe if I recall ...
Aargh! It's still not working!
The DLL is registered (the reference is actually pointing at the TLB). There are no missing references. It fails with error number -2147024894:
The system cannot find the file specified.
I can't see what file it is complaining about! The DLL and TLB are both in the folder that the reference points to and the reference itself is not 'missing' so what gives?
Here's the function where I instantiate the object:
Private Function InitWrapperObject() As Boolean If AFWrapper Is Nothing Then On Error Resume Next Set AFWrapper = New VBA_AF_Wrapper.Wrapper ‘ <-- This is the problem line. If Err.Number <> 0 Then Call LogMsg("Failed to initialise AF Wrapper object: " & Err.description, 1) End If On Error GoTo 0 End If
Any ideas? I am getting really frustated, this was supposed to have been polished off last week!
try regasm /codebase if you have several copies running around on the pc ...
Ok, that bit is sorted. I needed to run regasm with the /codebase switch. I also used the full path to the dll though I am not sure that was essential.
The next error was to do with some normal COM libraries that needed to be registered with regsvr32. That is now done.
The latest error appears to be to do with the AF libraries... I am getting the following exception:
Normal 0 false false false EN-US X-NONE X-NONE
Watch : - : Err : -2146233069 : Object/ErrObject : ThisDisplay.myCtxtHndlr_ContextChanged
: Description : "Method not found: 'OSIsoft.AF.AFNamedCollectionList`1<OSIsoft.AF.Asset.AFElement> OSIsoft.AF.Asset.AFElement.FindElementsByPath(System.Collections.Generic.IEnumerable`1<System.S"
: HelpContext : 1000440 : Long : ThisDisplay.myCtxtHndlr_ContextChanged
: HelpFile : "C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA6\1033\VbLR6.chm" : String : ThisDisplay.myCtxtHndlr_ContextChanged
: LastDllError : 0 : Long : ThisDisplay.myCtxtHndlr_ContextChanged
: Number : -2146233069 : Long : ThisDisplay.myCtxtHndlr_ContextChanged
: Source : "VBA_AF_Wrapper" : String : ThisDisplay.myCtxtHndlr_ContextChanged
So what is going on here then?
I do have a simple test function in the .NET library that just returns "Hello World" so I may try calling that after creating the object, just to test that the essentials work but it looks like this is an AF SDK issue.
Thanks David, just saw your suggestion about /codebase. That certainly fixed the issue at the time but now I have hit another![/edit]
Missing Method errors in .Net usually means that you are compiling against a different version of AF than is getting loaded at run time ..
Thanks, yes that is what we have found.The test machine was running an older version of the AF SDK than the dev system. Unfortunately, I can't remember what version the customer has!
It looks like all the PI related issues are now resolved or at least understood. Now we just have to do the same with issues around Excel automation!
I would recommend developing against AFSDK 188.8.131.525. That's what ships with PB 3.1, which is the earliest version that installed AFSDK (I believe). Unless you are deploying AFSDK yourself to use with older versions of PB or need the features of the newer AFSDK.
What version ships with Processbook 3.2? Can I just uninstall my AF Client 2010 and install AF Client 184.108.40.20624 (which I think is the version they have)? That is what I will try and then see if the DLL still builds.
Well I now seem to have AF SDK 220.127.116.1124 but at runtime, I get the following error:
Run-time error '-2146233069 (80131513)':
Method not found:
What would be the best way of replicating the functionality of FindElementsByPath()? Is there a list anywhere of all the functions and objects added between 18.104.22.16824 and 2010r2?
PB 3.2 ships with AF 22.214.171.12498 it looks like. Check your references in your project and see what version you are compiling against.
For what it's worth, I just ran AFClient.msi of the expanded folder of the ProcessBook 3.2 install kit and this is what I got:
So, from an end user perspective, it looks like PI AF Client 126.96.36.19922 is shipped with ProcessBook 3.2.
@David: How did you get the information about the AF Client version shipped with ProcessBook 3.2?
You're right. I was being lazy and looking at what it's compiled against (which can vary slightly).
In the AFSDK reference help file, each method or property will indicate which versions it is included in in the "Version Information" section . For example AFElement.FindElementsByPath indicates it is supported in AF 2.3 only.
Additionally, here is the list of new classes, methods, and properties in the AF 2010 (2.3) and AF 2010 R2 (2.3) releases:
AF 2010 R2 (188.8.131.5248)
The AF 2010 R2 release focused on providing the necessary capabilities to support the PI AF Builder Excel add-in.
The classes OSIsoft.AF.AFCsvColumn and OSIsoft.AF.AFCsvColumns are used to query AF SDK objects CSV (Comma Separated Value files) column definitions and specify them for exporting from AF using PISystem.GetCsvColumns. The methods PISystem.ImportCsv and PISystem.ExportCsv are provided to import and export CSV files.
The new export mode PIExportMode.Flat allows hierarchical objects to be exported in a flattened style. The new import mode PIImportMode.DeleteOperation is used within CSV import to delete objects found within.
The method PISystem.GetRpcMetrics returns server performance metrics to the client. The method PISystem.GetObjectCounts returns counts of allocated objects in the associated PISystem or specified Database.
The method PISystems.Refresh(Boolean) provides a Boolean parameter which allows only the list of PI Systems to be refreshed. Without the parameter, the top-level contents of connected PI Systems are also refreshed.
Overloaded methods AFAnalysis.SetStatus are provided to efficiently set the status for a single analysis, or a list of analyses, without requiring check-out and check-in of the AFAnalysis.
The method AFElement.FindElementsByPath provides efficient lookup of elements by path.
Paging support is added to the method AFElement.GetEventFrames
The method AFElementTemplate.GetAllCategoriesString provides a mechanism to return the category string for an element template which includes the base templates.
The method AFVersion.GetParents gets the list of all parent objects of the owner object without regard to the query date.
A new class, OSIsoft.AF.Diagnostics.AFRpcMetric, is used to return server performance metrics to the client.
The method AFEventFrame.FindEventFramesByPath provide efficient lookup of event frames by path.
The property AFEventFrame.PrimaryReferencedElement provides a mechanism to indicate the primary element associated with an event frame. By default, the first element referenced will be the primary element. The data references support access to this property via the special syntax .\Elements[.].
Overloaded methods AFNotification.SetStatus are provided to efficiently set the status for a single notification, or a list of notifications, without requiring check-out and check-in of the AFNotification.
The methods AFNotificationContactTemplates.Swap and AFNotificationContacts.Swap are provided to change the order of existing subscribers within a group without having to delete and recreate the entries.
A new constructor AFTimeRange.AFTimeRange(String, String) provides simpler construction of AFTimeRange objects.
The AF 2010 release focused on providing major performance and scalability improvements, as well as handling large number of elements within one level of the element hierarchy. Support for the PI 2010 Server release and AFLink was also included.
A new connection protocol, specified with the enumeration AFConnectionProtocol.NamedPipe, was added.
The property AFAttributeVariable.IsOptional indicates if a variable to an Analysis is optional.
Methods for retrieving and searching for elements now provide optional paging parameters. Modified methods include: AFElement.FindElements, AFElement.FindElementsByAttribute, AFElement.FindElementsByCategory, AFElement.FindElementsByReferenceType, AFElement.FindElementsByTemplate, AFElement.GetElements, AFVersion.GetChildren, AFElement.GetParents and AFElementTemplate.FindInstantiatedElements. To keep large element collections from being paged out of memory, use the new property AFElements.KeepInMemory.
The method AFElementTemplate.GetAllAttributeTemplates provides an easy way to retrieve all attributes for a template, including base templates.
Loading a hierarchy of event frames into the AF SDK can be accomplished with AFEventFrame.LoadEventFramesToDepth.
The property AFNotificationContent.TemplateContent returns the AFNotificationContent from the AFNotificationTemplate that was used to create the content, otherwise, it returns null.