1 of 1 people found this helpful
In short, you need to build the AFWrapper project and then you can reference it in PI ProcessBook.
- Open AFWrapper.sln in Visual Studio.
- Make sure the project is using OSIsoft.AFSK reference build against version 184.108.40.206 CLR (Can be found in the reference properties)
- Set Target Framework to .NET 3.5 (in Project->AFWrapper Properties)
- In the Solutions Explorer do a right-click on the AFWrapper project and choose Build.
That's it. When you open PI ProcessBook VBA editor you should be able to see AFWrapper in the list of references (Tools->References).
Add AFWrapper reference and you should be good.
For the example PDI file provided with AFWrapper, you need to import AFElements.xml into a new test AF Database.
A couple of bumps I hit while getting AFWrapper to work:
- Got an exception ("ActiveX can't create object") on the following line in the example VBA:
Set AFW = New Wrapper
Fixed it by qualifying the reference:
Set AFW = New AFWrapper.Wrapper
- Not related anyhow to AFWrapper: Somehow my PB 2014 was missing the Element Relative Display feature, so ProcessBook threw an exception on the Set ERD line. This was fixed by repairing the ProcessBook installation.
I followed your instructions and it worked like a charm.
At first when I imported into Visual Studio Professional 2013 I was greeted with this warning "Visual Studio needs to make non-functional changes to this project in order to enable the project to open in Visual Studio 2013, Visual Studio 2012, and Visual Studio 2010 SP1 without impacting project behavior." and asked if I wanted to proceed, I clicked [Yes]. VS 2013 automatically 'upgraded' it to .Net Framework 4.0 so I had to fix that per your instructions. When I first opened the WrapperExample.pdi file I encountered a few issues like you such as the Set ERD line, but was able to quickly solve them. Also, for the purposes of development I set up a separate AF Database and then imported the AfElements.xml file. Back in the ProcessBook WrapperExample.PDI display this required I delete the existing element relative tree and then import the newly created set of AF Elements. After that the WrapperExample.PDI display ran error free.
Glad you got the wrapper working! One word of caution: since you had mentioned you programmatically access MDB from ProcessBook, I wanted to point out that AFSDK does not support accessing MDB directly. For accessing MDB, PISDK is still required. For most other data access needs, you should use AFSDK.