EViews COM Automation versioning...

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

EViews COM Automation versioning...

Postby EViews Steve » Thu Apr 07, 2016 9:50 am

As more of you have started making use of our EViews COM Automation interface (to control EViews and to send/receive data), I thought I would write a quick post about dealing with a few "gotchas" when releasing a program you wrote for your users that depend on EViews COM. In particular, dealing with users that could have different versions of EViews installed.

Which version of EViews should my program target?
As of now, we've released three different versions of EViews that support COM Automation (EViews 7, 8, and 9). Each subsequent version introduced changes/improvements to the main EViews.Application interface. The three type libraries are:
  • EViews 1.0 Type Library ( for EViews 7 )
    EViews 8.0 Type Library ( for EViews 8 )
    EViews 9.0 Type Library ( for EViews 9 )
To make sure your programs continue to work with newer versions of EViews, we made sure to include all older type libraries in each new version. Meaning, if you install EViews 9, it will register not only the 9.0 type library, but also the 8.0 and 1.0 as well. (Actually we didn't include the 8.0 type library with 9 until the recent March 17 2016 patch.)

This means that if your program is statically dependent on the 1.0 type library, it will work on any user machines that have EViews 7 or newer installed. Likewise, if your program is statically dependent on the 8.0 type library, it will work only for those users with EViews 8 or newer. And so on...

Static vs Dynamic References
Now having your program statically linked to one of our type libraries is helpful during development since most development environments these days (like Visual Studio) will show all of an object's methods while you are using it (like Visual Studio Intellisense). But it does have a major disadvantage in that if your user doesn't have EViews installed at all, your program will fail to even start (so you wouldn't be able to tell them why you couldn't start).

Now since all of our COM objects support the IDispatch interface (which means you can call our object methods by name), you don't have to statically reference our type library to use them. As an example, you can do the following in VB.NET without having any EViews references at all:
example1.png
example1.png (5.16 KiB) Viewed 1972 times
The advantage of this approach is that your program will load and run even if EViews isn't installed on the target machine. You can easily check to see if a manager object was returned by the call to CreateObject and if it wasn't, you can report it as an error to the user.

Another advantage is that you can call easily test for and use newer methods that might not exist in the Application object that you have. For example, if the target system only has EViews 7, and you tried to call app.Get2D (which only exists in EViews 8 and newer), you would get an exception (in a .NET environment, you would see a System.MissingMemberException). You can simply catch this exception and show an error to the user (saying something like: You must have EViews 8 or above to use this feature) or you can code in a workaround by using our 1.0 interface methods instead.

The disadvantage is that, again, you will lose the helpful intellisense dropdowns during development. An easy workaround for this is to do your development using one of our statically linked type libraries. But once you're ready to release, remove the static reference and then change your EViews variable types to Object. Aside from changing some EViews enumerated types to constants, you should be able to compile this "reference-less" version easily.

Detecting an EViews Version
If your program needs to know if a particular version of EViews is available, you can simple call CreateObject with these particular version-specific COM ProgIDs to see if they return an object or not:
example2.png
example2.png (5.53 KiB) Viewed 1972 times
Then you can easily test to see if an object was returned. Because newer versions will install older references, you'll have to test for these from newest to oldest to be sure of which version you have.

More Information
There's more discussion of these issues in our whitepaper. Look for the section named "Choosing an EViews Version".

Steve

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest