首页 > 解决方案 > Vector CANoe - 如何构建具有多个 C# 文件的 .NET 测试节点?

问题描述

目标
我想使用 Vector CANoe C# (.NET) 脚本功能。
更具体地说,我想通过构建一些核心实用程序类来降低 .NET 测试节点的复杂性。

例如,而不是拥有这个

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

一个对象可以这样做:

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

为了实现这一点,我的计划是构建一个utilities.cs每个 .NET 测试模块都会使用的文件。
思路大致是这样的:

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

问题
我不能让编译器满意。我总是收到错误 CS0246。在 CANoe 控制台中:

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?)

使用 Visual Studio 时,我的解决方案构建没有问题。

问题
如何构建具有多个 C# 文件的 .NET 测试节点?

标签: c#.nettestingcanoe

解决方案


我认为您utilities.cs在 CANoe 测试配置中选择了该文件。

使用该设置,CANoe 将仅编译单个文件,即使您可以在 Visual Studio 中编译整个项目。

但是,CANoe 不仅支持.cs文件,还支持.dll.sln文件。

了解这一点后,您可以简单地更改配置以使用 Visual Studio 项目的解决方案文件或输出 DLL 文件。


注意:我遇到了同样的问题,我在寻找解决方案时发现了这篇文章。

推荐阅读