-1

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

  1. Vector-Canoe 11 - SP3 (64 bit).
  2. 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

  • Hello, and welcome to stack overflow. Your post came up in a review queue, so I fixed the formatting of your code to make it readable. See [How do I format my code blocks?](https://meta.stackexchange.com/q/22186) for formatting guidance. I also added the necessary tag [tag:canoe]. Since you have a question about a very specific topic, you need to tag it correctly to attract experts on that topic. See: [What are tags, and how should I use them?](https://stackoverflow.com/help/tagging). Good luck. – dbc Aug 16 '20 at 04:21
  • 1
    You also wrote, *Here is the exception I get due to the line of code* -- but I don't see the exception, only the code itself. Might you please [edit] your post to include the full `ToString()` output of the exception (as text, not as an image) including the exception type, message, traceback and inner exception(s) if any? – dbc Aug 16 '20 at 04:24
  • I added the exception, thanks so much. I hope I would get the solution – SalehTarek Aug 16 '20 at 07:33

1 Answers1

0

The „weird“ names you get simply denote the name of the interfaces that have evolved over time.

The started with CAPL, when new functionality was added, Vector could not change the existing interface because that would break backwards compatibility. So they added ICAPL. The next version was ICAPL1 and so on.

This interface is provided by the CANoe.CAPL object. You should not care about the exact version of the interface.

Regarding the exception you get, I think this is because you try to access the Devon Test environment ( at index 1), while there is only one Test environment.

For your other problems no method X on object Y you would have to provide more details.

MSpiller
  • 3,500
  • 2
  • 12
  • 24