How to fix "error CS0234: The type or namespace name 'CommandHandler' does not exist" in Connext DDS C# examples

Note: The following information applies to RTI Connext DDS 6.1.0 - 6.1.0.3.

Many code examples for the Connext DDS C# API, including those generated by rtiddsgen, use the .NET package System.CommandLine to parse the options passed to the application.

A recently released version of System.CommandLine included breaking changes. The Connext examples did not lock the required System.CommandLine version and therefore may automatically download the latest version, which causes the following compilation error:

error CS0234: The type or namespace name 'CommandHandler' does not exist in the namespace 'System.CommandLine.Invocation'


How to fix this error

To fix this error, simply update the example .csproj file to use a previous System.CommandLine version.

You can do this using the dotnet CLI:

dotnet add package System.CommandLine --version 2.0.0-beta1.21308.1

Or by editing the .csproj files and replacing: 

<PackageReference Include="System.CommandLine" Version="2.0.0-*" />

With:

<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />

Note that this package is only used to parse the options for the example. Once you write your own application you may no need to use this package anymore.

Programming Language: