-1

I'm trying to execute some CAPL functions in a specific CANoe Configuration through the CANoe-COM server in C#. But I'm running into errors.

Here, I'm declaring objects of two classes in the CANoe-COM server : Application(to open a CANoe Configuration) and CAPLFunction(to run some CAPL functions on the Configuration,say,open a panel), on the press of a button in a simple Windows Form. The code is as follows:

    private void button1_Click(object sender, EventArgs e)
    {
        CANoe.Application CANoe_big = new CANoe.Application();
        CANoe_big.Open(@"All_neu.cfg");

        CANoe.CAPLFunction Neu = new CANoe.CAPLFunction();

    }

When I'm typing out these functions into Visual Studio, there are no errors indicated. Even on running the program, the Form does show, and on clicking the button, the configuration "All_Neu.cfg" also opens. But after that, the system's throwing this error : "Class not registered, HRESULT:REGDB_E_CLASSNOTREG". And it's highlighting the line declaring the CAPLFunction object while throwing the error.

Which is weird, because there should be no problems,right? I mean, the CANoe configuration is opening correctly, so the CANoe-COM server is alive and kicking.

In fact, I have noticed that any object of literally ANY other class in the COM server,like Bus or Write, is resulting in the same error. The configuration does open, but after that, nothing.

Any ideas as to why this is happening?

  • That could be a x86 vs x64 issue as COM class registration is separated for each environment. For example, the COM server runs in x86 and the client is x64, or the reverse. – Simon Mourier Mar 26 '19 at 06:38

1 Answers1

0

You cannot create a free-floating, empty CAPLFunction object.

The CAPL function has to be present in the Config you have just opened. After that you can get it by

var caplFunc = CANoe_big.CAPL.GetFunction("<functionname>");

You can then execute it by calling

caplFunc.Call(...);

Check the part called Technical References -> COM Interface -> Object Hierarchy in the CANoe documentation.

MSpiller
  • 3,500
  • 2
  • 12
  • 24