4

Community.

Details

tl;tr: I have a Raspberry Pi 4 and a self-contained C# service running on .NET Core 2.2.
Since some libaries are obsolete in higher versions I have to stick with 2.2.

My workplace is writing code in vb.NET and they also use their own vb.NET-.dll's in general.
Now they want me to write the whole service in vb.NET but I am unsure if vb.NET is even able to run as a service on .NET Core on Raspian.

tl;tr: Rasperry Pi4, Raspbian, .NET Core 2.2, service running with C#, company codes in VB.NET

In general my question is:
Is it possible to run a self-contained vb.NET service on .NET Core on Raspian?

Please add, if available, some sources or recommend books/websites I can read into for educational stuff.(So I can avoid asking questions)

Research

I searched in the official dokumentation. I only found sth. about general Visual Basic stuff. https://learn.microsoft.com/en-us/dotnet/core/

Also I searched right on SO and found out about vb.NET and Mono: Visual Basic .Net in Linux

And another one with Mono: Running VB.NET script with mono on a raspberry pi

Also Mono-based: VB.net on Raspbian OS (Linux & Mono) fyi: None of my colleagues has worked with a raspberry pi yet and they gave me the same links you see above.

But none of them answer my question in particular.

Code

I don't think that code is needed, bc it's not a code-based question.

Thank you in advance, hoping this question is not as dumb as I think it sounds.

Community
  • 1
  • 1
TheMaDimon
  • 43
  • 3
  • The language doesn't matter, only the runtime – Panagiotis Kanavos Jun 05 '20 at 08:10
  • Indeed as Panagotis indicates, vb.net and c# are the same language when compiled, they're just different syntaxes to appeal to different people. You can add projects of both (all) syntaxes of .net to a single solution and debug, stepping back and forth between c# and vb every time you press Fwhatever if you want - that usually makes it pretty clear :) – Caius Jard Jun 05 '20 at 09:21
  • I'm actually kinda confused now as to what you're asking-if you're asking about converting c# to vb, it can be done programmatically because they're the same thing underneath. Search for c# to vb; even web converters exist, as well as plugins/extensions for VS. Or just learn vb and translate your lines to it. The hardest bit is probably remembering the wacky line ending conventions (sometimes do, sometimes don't need line end markers _ ) in the absence of semicolon – Caius Jard Jun 05 '20 at 09:32
  • @CaiusJard sorry for the confusion. I am not trying to convert it from c# code to vb. I will do that, but this is not the problem for me. I am trying to figure out, if it is possible to run a service, written in vb.net, on a Raspbian device. (Raspberry Pi 4) Runtime is ASP.NET Core Runtime 2.2.8. Edit: just saw that you also answered. So I guess it's a little less confusion, since you answered. – TheMaDimon Jun 05 '20 at 09:48
  • If someone can run C# code https://taras.codes/blog/hosting-an-asp-net-core-application-on-raspberry-pi-3/ then your VB.NET code can do the same. – Lex Li Jun 05 '20 at 14:34

1 Answers1

1

In a simplified nutshell

  • Linux Mono = Windows .NET Framework
  • Linux .NET Core = Windows .NET Core

As your service is .NET Core, you should avoid looking at Mono; it will add to the confusion


https://levelup.gitconnected.com/net-core-worker-service-as-windows-service-or-linux-daemons-a9579a540b77 says:

On windows, Add a reference to Microsoft.Extensions.Hosting.WindowsServices NuGet package then call UseWindowsService() on your HostBuilder

On Linux, Add a reference to Microsoft.Extensions.Hosting.Systemd NuGet package, then call UseSystemd() on your builder

Edit; just saw you're stuck on 2.2 - not sure this advice after the horizontal rule is relevant but I'll check

Caius Jard
  • 72,509
  • 5
  • 49
  • 80
  • thank you so much @CaiusJard. I did some research and found out, that it is indeed possible to load vb.net dlls into a c# .net core project and run it as a service on Raspbian. But a workerservice is not codeable in vb.net.( new project in visual studio and vb ist listed on workerservice) I haven't any sources bc I coded a simple c#-workerservice and just put a vb.net-dll in it- idk since when this is possible, but half a year ago, as I tried to go with companies' vb.net stuff it definetly didn't work. I put this as your answer since I tried it the way mentioned in the link. – TheMaDimon Jun 06 '20 at 09:56
  • 1
    Don't forget there isn't any such thing as "a vb.net dll" or a "c# dll" - they are IL DLLs; both vb and c# compile to IL and become the same thing. Also don't let the lack of a particular project template lead you do think that something is available in c# but not vb - project templates are just that and can be installed at will, and just contain some lines of code and references that are available in the runtime. You won't find workerservice in .net 2.2; that's not a vb or c# thing, it's a march-of-progress-of-the-runtime thing- it was added in 3.x – Caius Jard Jun 06 '20 at 10:12