2

Objectives
I want to use the Vector CANoe C# (.NET) scripting capability.
More specifically, I want to reduce my .NET test nodes' complexity by building some core utility classes.

For example, instead of having this

// With the Vector API directly
IVT2516Channel M4_Ch9 = vts.GetChannel("M4_Ch9");
M4_Ch9.DigitalOutput.Value = true;

An object could do this:

// With an Object that abstract the Vector API
MyECU ecu = utilities.MyECU();
ecu.OpenContactor(True);

To achieve this, my plan was to build a utilities.cs file that every .NET tests module would use.
The idea is roughly this:

+---------------------------+
| CANoe Test environment    |
|                           |
|   +--------+ +--------+   |
|   |  .NET  | |  .NET  |   |
|   |  test  | |  test  |   |
|   | module | | module |   |
|   +--------+ +--------+   |
|        |         |        |
+--------|---------|--------+
         |         |
+--------v---------v--------+
|                           |
|    CORE UTILITIES (C#)    |
|                           |
+---------------------------+
             |
+------------v--------------+
|                           |
|       VECTOR Modules      |
|                           |
+---------------------------+

Problem
I can't get the compiler happy. I always get error CS0246. In the CANoe console:

System  Testmodule 'Test 1': Compilation of tests_wakeup.cs' failed with error(s)
System  tests_wakeup.cs(17,7): error CS0246: The type or namespace name 'utilities' could not be found (are you missing a using directive or an assembly reference?)

When using the Visual studio, my solution build without problems.

Question
How do you build a .NET tests node with multiple C# files?

dan1st
  • 12,568
  • 8
  • 34
  • 67
gberth
  • 467
  • 5
  • 13
  • What did you configure as your testmodule? A (c sharp) source file or an assembly? – MSpiller Jul 03 '20 at 09:51
  • @M.Spiller I'm not very familiar with the c# assembly process, so a tried everything I could think of: as a c# project, a .cs source file and a .dll file. They all produce the same kind of error and they all built without error in Visual Studio. – gberth Jul 03 '20 at 16:42

1 Answers1

2

I think you selected the file utilities.cs in the CANoe test configuration.

With that setting, CANoe will only compile a single file, even if you can compile the whole project in Visual Studio.

However, CANoe does not only support .cs files but also .dll and .sln files.

Knowing this, you can simply change your configuration to use the solution file of the Visual Studio project or the output DLL file.


Note: I had the same problem and I found this post while looking for a solution.
dan1st
  • 12,568
  • 8
  • 34
  • 67
  • This solved my issue. For documentation purposes: In the CANoe tests setup window, you can add a `.NET tests module`. This tests module can as mentioned by @dan1st, you can add a visual studio `.sln` files. This will force CANoe to compile your multiple file solutions. Thanks again Sir/Madam. – gberth Jul 14 '20 at 18:22
  • As I said, I had the same issue :) – dan1st Jul 14 '20 at 19:50