question

FrankSarlemijn-9053 avatar image
0 Votes"
FrankSarlemijn-9053 asked FrankSarlemijn-9053 commented

howto develop c# on raspbian and vs 2019

I would like to write a simple file transfering app on a SBC. I have chosen raspberry pi for this. Windows IoT proved to be unreliable and I gather from the web that Microsoft stopped the development of this in favor of using Linux (in this case raspbian) as OS. Correct so far? Visual Studio can crosscompile for ARM processers and it can do remote debugging. I am having trouble getting to remote debug an app on the raspberry pi. Setting authentication mode to 'universal' in VS gets a dialog asking for a PIN number, setting the authentication mode to 'none' tells me that msvsmon.exe is not running on the remote computer. My last development experience is 10 years ago, I need some pointers to get these modern developments working, thank you!

vs-debuggingvs-setupdotnet-iot
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm not aware that VS can cross-compile to ARM for the pi.
I've used it to remote develop/debug to a pi using this method.


0 Votes 0 ·

Sorry for the confusion. Code has to go a long way from c# to execution. As i understand it, VS changes my code from c# to IL. This IL gets deployed on the target machine and then compiled at runtime to native executable instructions. These days .net Core can do the last steps (compiling to native instructions) also on a ARM (linux) machine. Correct?

What I think is possible is generating IL on my Windows machine, transfering this to the raspi. Letting the .net Core on this machine handle the translation to native instructions. Attaching my Windows debugger to thus created process on the raspi and debug this way on my Windows machine. I used to this on windows only machines. I think with .net Core on linux this is the model to go for? Or is my thinking completely wrong?

Is the solution you are proposing facilitating this?

0 Votes 0 ·

I've not tried doing any C#/.NET core development on Linux. What you say sounds reasonable to me. Have you tried starting from a new project: Console App (.NET Core) ?

0 Votes 0 ·

yes. I found that i can change project settings to accept my raspi as target and change the output to ARM compatible. Alas I find deployment errors. Setting authentication mode to 'universal' in VS gets a dialog asking for a PIN number, setting the authentication mode to 'none' tells me that msvsmon.exe is not running on the remote computer. I am at a loss at this point

0 Votes 0 ·

Perhaps I'm not understanding the question but it's perfectly fine to just recompile your .Net Core C# code on an ARM32 device like the Raspberry PI or a 64 bits device like the NVidia Jetson Nano.

Just install the right .Net Core SDK and use a cross platform tool like VS Code (as an alternative to compile and run from the prompt).

Happy coding!


0 Votes 0 ·

1 Answer

DavidLowndes-6766 avatar image
0 Votes"
DavidLowndes-6766 answered FrankSarlemijn-9053 commented

Using the instructions here worked for me.

I created a .NET Core console project using the latest VS 2019, changed its project settings to be .NET Core 5 (it's created as 3.1).

On the Pi (a 3B which already had the prerequisites installed to have an SSH connection), I downloaded .NET Core 5, followed the installation instructions on that page and checked that dotnet ran.

I copied over the built .net5.0 project binaries from Windows to my Pi using WinSCP.

Using the Pi, I determined that the console DLL could be run by dotnet MyCodeName.dll.

While the code is running (I'd stuck a Console.ReadKey() line in), I could attach with the VS debugger using the instructions given.

It's a slight faff compared to the relatively seamless experience of native code, but it worked.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you. I was able to install .net Core 5 change the project output and compile, run and debug a console application. This was the goal of my question, very good pointers!

0 Votes 0 ·