Can VB be used for a net core api project?

Larry Widing 21 Reputation points

I have an existing web api project written in VB. All the examples for converting to net core 6.0 use C#, and Visual Studio will only create a Web API project using C#.

Can this be done with VB? And if so, what steps are required to do this?

And converting to C# is not, at this time, an option, so please no comments about why we should be using C#, thank you!

A set of technologies in the .NET Framework for building web applications and XML web services.
4,249 questions
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,610 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 49,251 Reputation points

    Can you? Yes, it is .NET after all and any .NET language can be used to write .NET apps. VB is supported on .NET 5 as a platform including ASP.NET Core.

    Does it have full feature support and templates? No. And based upon what MS has said there are no plans to provide such templates.

    However MS has bounced back and forth between VB being fully supported and not. We are back in the "not the future" phase and with .NET 6 MS said they didn't see VB as viable for ASP.NET Core. VB does support .NET 6 as you can partially read here. But the runtime is evolving to support more questionable, performant, newer cases and some of that requires language support. MS has made it clear that C# is the language for that. So you could write an ASP.NET Core app in VB but you might run into some scenarios where VB doesn't have the language constructs needed to properly work with some changes in the framework. I'm not aware of any at this time that are critical. But you'll have to do the legwork to convert the C# project templates to the equivalent VB templates.

    As an aside, one "migration" approach is to keep all your code in VB but create the ASP.NET app itself in C#. Since the bulk of your code is likely backend then it remains in VB as normal and just the front end controller/runtime stuff would be sitting in C#. It isn't ideal but would be a bridge.

    Another approach might be to migrate your app to .NET Core 3.1. This did support VB if I remember correctly. Once you have the project migrated you can more easily upgrade that project to .NET 6 as the changes are minimal.

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,046 Reputation points Microsoft Vendor

    Hi @Larry Widing ,

    Check this Microsoft statement

    Starting with .NET 5 Visual Basic will support:

    • Class Library
    • Console
    • Windows Forms
    • WPF
    • Worker Service
    • ASP.NET Core Web API

    Going forward, we do not plan to evolve Visual Basic as a language. This supports language stability and maintains compatibility between the .NET Core and .NET Framework versions of Visual Basic.

    I check it on the latest version of VS 2022 (Version 17.1.1), at present, it doesn't provide the related templates for API application.

    And I also find this issue (Add ASP.NET Core Visual Basic project template). It seems that the current development team has no plans to add VB templates.

    So, you can create a C# core API application, then try to convert the code from C# to VB.Net by yourself.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    1 person found this answer helpful.
    0 comments No comments

  2. AgaveJoe 26,246 Reputation points

    Visual Basic is NOT an option in Web API Core 6.0.

  3. Bruce ( 58,126 Reputation points

    It is pretty clear that is targeted to support windows only development. Its cross platform support is limited to libraries and console apps. If you are writing windows desktop apps, is strong contender.

    If you want to do web, mobile, and Maui development, with .net core you should make the migration to C#. you can use your old vb code as libraries, but should write new code in C#.

    If you have a group of developers that can not move to C#, and you need to write .net core web or cross platform applications, then they will be limited to class libraries and unit tests.

    0 comments No comments