1

I am trying to develop a C# application that contains a managed MQTT client. I am using MQTTnet and MQTTnet.Extensions.ManagedClient. I have seen some examples of how to do this using MQTTnet version 3.0.16. I have downloaded and built a project that implements an MQTT client using this pair of nuget packages.

When I allow Visual Studio 2022 to update the nuget packages (MQTTnet and MQTTnet.Extensions.ManagedClient) to the latest versions (4.2.1.781 and 4.2.1.781, respectively), Visual Studio reports design-time errors related to the following namespaces missing: MQTTnet.Client.Connecting, MQTTnet.Client.Disconnecting, MQTTnet.Client.Options, MQTTnet.Client.Receiving.

Does this indicate that the latest version of MQTTnet has significant changes? If so, are there more modern examples for using MQTTnet and MQTTnet.Extensions.ManagedClient?

I used MQTTnet version 3.0.16 successfully. When I upgraded to version 4.2.1.781, the example no longer compiled.

  • Yes, there are breaking changes in v4 - see the [upgrading guide](https://github.com/dotnet/MQTTnet/wiki/Upgrading-guide) for a summary of the changes. – Brits May 29 '23 at 19:00
  • Changes from v3 to v4 are quite major. Take a look at the github [repository of mqttnet](https://github.com/dotnet/MQTTnet/). It contains Samples of how to do basic tasks, including some for [ManagedClient](https://github.com/dotnet/MQTTnet/blob/master/Samples/ManagedClient/Managed_Client_Simple_Samples.cs). *Beware*: the wiki still refers to v3 of the library and does not get updated – Jeanot Zubler Jun 01 '23 at 13:42

1 Answers1

0

I haven't tried it yet, but I did find a sample using MQTTnet version 4: https://blog.behroozbc.ir/mqtt-client-with-mqttnet-4-and-c

modified answer: I have found and tried https://github.com/SeppPenner/MQTTnet.TestApp.WinForm, which uses MQTTnet Managed Client version 4. Actually, it is a Windows Forms app (.NET Core) that appears to have been developed without using the new GUI designer in Visual Studio. I have moved the source into a Windows Forms app (.NET Framework, since GUI designer is still preview). It works well.

rob2universe
  • 7,059
  • 39
  • 54