How Convert VB Project to C# Project

96,350

Solution 1

I am assuming you tried SharpDevelop 5 since the conversion feature was missing in that version.

The VB to C# code converter from the SharpDevelop team is now a standalone extension to Visual Studio. Once installed, you can convert an entire VB.NET project to C# by opening the solution, right clicking the solution node in the Solution Explorer and selecting Convert to C#.

Solution 2

Sorry but I've not come across any tools that will convert the entire project. I've just created a interim c# project and converted small parts at a section at time, in the past. The conversion is not a straight one-2-one code map for a variety of reasons due to the differences in the languages. Small steps and some good unit testing help speed things up. Alternatively if your code uses code generators tools supplied by CodesmithTools, they often have compiler switches that will help change .net languages. This will definitely help in my humble opinion.

Share:
96,350
Romo Daneghyan
Author by

Romo Daneghyan

Updated on June 17, 2020

Comments

  • Romo Daneghyan
    Romo Daneghyan almost 4 years

    I have a project written in VB, and I need to convert the whole project to C# project. I don't want to do it file by file, I found some online converters, but they convert only lines of codes, not the whole project. I found on researches, and here was written that I saw this question , there was written that

    "The best part about Sharpdevelop is it converts the whole project (source files) from VB and C# and the other way"

    And I also researched on Google, that if you Right Click on the project, I found here , that "Right click on the project in the Projects window and select Convert - From VB.NET to C#". But when I right click on The Project in the Projects window, I can'd find that "Convert". Is there any tool I have to install for SharpDevelop and then I will be able to convert my project ? Thanks

  • Romo Daneghyan
    Romo Daneghyan over 9 years
    Thanks for your answer. I guess I have to convert the project converting files one by one :)
  • Romo Daneghyan
    Romo Daneghyan over 9 years
    oh, I did not know that. Yes, I was using Sharp Developer 5. I installed the SharpDeveloper 4.4 and there was that tool for converting. Thank you @Matt Ward :)
  • kdbanman
    kdbanman over 8 years
    Such a familiar stackoverflow pattern. A common question viewed thousands of times with a correct and specific answer that's high up on the google results for related queries! :-) ...closed as off-topic.
  • Toolkit
    Toolkit almost 7 years
    did they revove it from SharpDevelop 5? How come?
  • Matt Ward
    Matt Ward almost 7 years
    @Toolkit - It was removed because SharpDevelop 5 does not support VB.NET.
  • Oleg Sh
    Oleg Sh almost 7 years
    I downloaded SD 4.4, but can't open VB.NET project: --------------------------- Error --------------------------- Error loading C:\www\3MD Inc\3MDinc\3MDinc.vbproj: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\M‌​icrosoft.WebApplicat‌​ion.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\www\3MD Inc\3MDinc\3MDinc.vbproj
  • Ashish Shetkar
    Ashish Shetkar over 6 years
    am facing the same issue on importing project in SD-4.4 , @OlegSh - you got any leads , is there any other way to do it
  • Matt Ward
    Matt Ward over 6 years
    I would try adding a condition to the Import that checks it exists or just comment out the import.
  • tmighty
    tmighty over 6 years
    Instant CSharp is the best but it costs money.
  • Kershaw
    Kershaw about 6 years
    @Oleg Sh I am sure you got your problem sorted out, but I found a solution to that Microsoft.WebApplication.targets error. I copied the WebApplications folder from this path: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0 to this path: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0 Then I reloaded the solution in SharpDevelop 4.4 and all was well.
  • Pap
    Pap over 5 years
    Please note that the extension is only available for VS2017. Won't install for older versions of VS. So you may need to download the standalone version of SharpDevelop if you are using older versions of VS.
  • mattboy
    mattboy about 5 years
    @kdbanman This question is now the highest in the Google search results. How ironic.