I am trying to use the COM Server Interfaces in a C# program to run a specific Test Module in a Canoe project. ------> Given that: I am using
- Vector-Canoe 11 - SP3 (64 bit).
- Visual Studio 2017.
I tried to follow the Hierarchy of COM Objects in the Vector-Canoe Technical Help, but I kept getting exceptions (Like: there is no method called x in in object Y).
I searched a lot, but it seems like no body's encountered this problem before.
Finally, I decided to print out the names of the objects to the console window, and it turned out that the names I get on the console window output doesn't match the objects' names mentioned in the Vector-Canoe Technical Help. For instance, I get:
- ICAPL5 instead of CAPL
and - ITestEnvironments instead of TestEnvironments and
- ITestEnvironment2 instead of TestEnvironment - etc....
Here are my C# code snippets:
using System;
using Vector.Tools;
using Vector.CANoe.Runtime;
using Vector.CANoe.Sockets;
using Vector.CANoe.Threading;
using Vector.Diagnostics;
using Vector.Scripting.UI;
using Vector.CANoe.TFS;
using Vector.CANoe.VTS;
using ASAM.HILAPI.Interfaces;
using ASAM.HILAPI.Implementation;
using Vector.CANoe.ASAM.HILAPI;
using NetworkDB;
using System.IO;
public class Canoe_autoFlash : TestModule
{
private CANoe.Application mCANoeApp;
private CANoe.Measurement mCANoeMeasurement;
private CANoe.CAPL CANoeCAPL;
private CANoe.TestEnvironments mTestEnvironments;
public Canoe_autoFlash() // Constructor
{
//1. Initialize mCANoeApp:
mCANoeApp = new CANoe.Application();
//2. Initialize mCANoeMeasurement:
mCANoeMeasurement = (CANoe.Measurement) mCANoeApp.Measurement;
Console.WriteLine("mCANoeMeasurement object: " + Microsoft.VisualBasic.Information.TypeName(mCANoeMeasurement));
//3. Initialize CANoeCAPL:
CANoeCAPL = (CANoe.CAPL) mCANoeApp.CAPL;
Console.WriteLine("CANoeCAPL object: " + Microsoft.VisualBasic.Information.TypeName(CANoeCAPL));
//4. Initialize mTestEnvironments:
mTestEnvironments = (CANoe.TestEnvironments) mCANoeApp.Configuration.TestSetup.TestEnvironments;
}
public void get_actual_objects_names() // This function is for debugging
{
Console.WriteLine("mTestEnvironments object: " + Microsoft.VisualBasic.Information.TypeName(mTestEnvironments));
Console.WriteLine("TestEnvironment object: " + Microsoft.VisualBasic.Information.TypeName(mTestEnvironments[1]));
Console.WriteLine("TestEnvironment object Item 1 name : " + ((CANoe.TestEnvironment) mTestEnvironments[1]).Name );
}
Here is the Console Window output showing the weird objects' names:
mCANoeMeasurement object: MeasurementClass
CANoeCAPL object: ICAPL5
Number of Test Envs = 1
mTestEnvironments object: ITestEnvironments
TestEnvironment object: ITestEnvironment2
Here is the exception I get due to the following line of code :
Console.WriteLine("TestEnvironment object Item 1 name : " + ((CANoe.TestEnvironment) mTestEnvironments[1]).Name );
The Exception is: System.Runtime.InteropServices.COMException: 'Test environment object not found.'
I would be immensely grateful if you let me understand the reason behind these weird objects names and how to get the right objects, so that I will have no problem following the object hierarchy in the Vector-Canoe Help