Edited by Danny5678 at 27-08-2021 15:49
Hello everybody, I needed to get this to run on a Raspberry Pi, but in doing so I created a 'universal' program that should be able to work on any Linux and Windows system. I couldn't find any information elsewhere on how to do this easily, so I thought I'd try to save everybody some time (Especially those who don't code often, like me) by outlining the basic principles and steps to creating a program using their C# API.
(I'm only an EE intern so go easy on me)
If you haven't already, download their libraries from:
If you want to, you can look at what they say to do. I found this helpful in implementing my solution, but there were a lot of holes in their explanations:
The process I describe will allow for running a program on Linux, but VisualStudio is the prefered IDE, which I think is Windows only.
This next part I just describe what I did. You can skip it if you're only looking to make a Windows.
If you downloaded csharplib.zip, there are 4 libraries. Unfortunately, there is a windows-only module imported into their ShizukuProtocol library, so I had to deal with it. I used dotPeek to copy and paste all the libraries in ShizukuProtocol into C#. Then, I went into the library "ShizukuDeviceScanHelper" and commented out 'using System.Management;' and every function that used System.Management.
To make this program run on Linux, you need to do something similar to what I did.
I'm not going to include my dll, since it is in bad practice to download dlls you're going to use in an executable from unverified strangers, so don't download it from me.
Now its time to make the project:
I used .NET 5.0, since the other framework wasn't working on my RPi for some reason. Add references to the libraries and do whatever other stupid stuff VisualStudio needs you to do. You might have to install some of the references I made.
My code might not be that efficient, since I don't really know what I'm doing, but it works. In the zip folder I attach, the code is called "Program.cs".
Just copy and paste the code from within to whatever you want. My code basically takes the dirty example that the creators provide and make it work for what I want. You can do the same with my code, to make something more usable for you.
Hopefully this guide and my code aren't too complicated. If there is enough demand, I will make the guide more understandable and useful. For now, I just wanted to hopefully save someone a few hours of headache and describe what I had to do to get it working on an RPi.