Simple .NET Core Application Using VB.NET
We take a look at how to create a simple .NET Core application using the sometimes-overlooked VB.NET. Come find out just how easy it is!
Join the DZone community and get the full member experience.Join For Free
.net core 2 preview 1 brings us support for vb.net on .net core. although tooling for web applications is not ready yet we can start with console applications and also some web applications like i will show in some of my later posts. visual studio 2017 preview 2 is needed to try vb.net out on .net core. this blog post is a short demo about how to build a simple utility application on .net core 2 preview 1 using vb.net.
what about asp.net core and vb.net? it’s coming, i’m sure. i was able to write pages and mvc applications on vb.net, but failed to get views working with tag helpers. web based apis that don’t require views can be written on vb.net already.
let’s write a simple vb.net application that runs on .net core. we start by creating a new application.
as a result, a new application with program.vb file is created. by default, program.vb contains just a main sub for application startup.
the application will download to a robots.txt file and saved to your disk. so, it’s a simple utility application. the code is here:
imports system.io imports system.net module program sub main(args as string()) dim request as webrequest request = httpwebrequest.createhttp("http://www.w3.org/robots.txt") using response as webresponse = request.getresponse(), file as filestream = new filestream("robots.txt", filemode.createnew) response.getresponsestream().copyto(file) end using console.writeline("press enter to continue ...") console.readline() end sub end module
after running the project there is a robots.txt file in the project root folder.
.net core 2 enables vb.net developers to join the .net core world. vb.net is here and will be fully supported by the .net core family from .net core 2 on. and it’s already possible to write utility applications on .net core using vb.net. also, writing web applications is supported, but the tooling is not ready yet. while vb.net is not yet fully compatible with .net core, it’s a good idea for vb.net developers to start playing with it today.
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.