Microsoft recently released version 6 of the .Net framework (formerly known as .Net Core). This version is supposed to be compatible with older versions of the framework, but in reality it isn't. We therefore had to fix some small problems in our library, in particular in the NuGet package.
It's easy to get lost with all the different versions of the .Net framework. After the ".Net Framework", the ".NET Core", Microsoft now uses simply ".Net". In any case, you just need to know that our C# library supports all flavors of .Net framework currently supported by Microsoft.
New example
In the Examples subdirectory of our C# library you will find many examples of Windows applications that target ".Net Framework 4.x" framework. These projects have been designed to run on Windows and must be opened and compiled with Microsoft Visual Studio.
In addition to these examples, we have recently added an example that uses the ".Net 6" framework. This example is in the Prog-dotNetCore folder . It does the same thing as the Doc-Inventory example (it prints to the console the list of modules connected by USB) but this example uses .Net 6 and works on Windows, Linux, and macOS.
The Prog-dotNetCore example code :
{
static void Main(string[] args)
{
YModule m;
string errmsg = "";
if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS)
{
Console.WriteLine("RegisterHub error: " + errmsg);
Environment.Exit(0);
}
Console.WriteLine("Device list");
m = YModule.FirstModule();
while (m != null)
{
Console.WriteLine(m.get_serialNumber() +
" (" + m.get_productName() + ")");
m = m.nextModule();
}
YAPI.FreeAPI();
}
}
Under Windows, this example can be compiled with Microsoft Visual Studio, or with the dotnet utility. On Linux and macOS, it is only possible to compile the example using the dotnet utility since Microsoft Visual Studio is not available for those OS.
Concretely, the dotnet build command is used to compile the example and the dotnet run command is used to run the application.
C:\YoctoLib.cs.48512\Examples\Prog-dotNetCore>dotnet run Device list RELAYLO1-27EAB (Yocto-Relay) YBUTTON1-2072D (Yocto-Knob) YPWMTX01-B9625 (Yocto-PWM-Tx) YPWMRX01-AE391 (Yocto-PWM-Rx)
The NuGet library
We also had to change our NuGet package to support the versions 5 and 6 of the ".Net" framework. If you need to add our C# library to an existing .Net project, you can do so using the following command:
dotnet add package Yoctopuce.YoctoLib
Conclusion
Our C# library works with all flavors of ".Net" frameworks as of today, and thanks to ".Net 6" you can use our modules on the following platforms:
- Windows 32 bits
- Windows 64 bits
- Linux Intel 32 bits
- Linux Intel 64 bits
- Linux ARM 32 bits
- Linux ARM 64 bits
- macOS 64 bits