Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / XML

A Free & Useful Converter from VB project to C# project

4.87/5 (5 votes)
3 Jun 2022CPOL2 min read 25.1K   1.6K  
This tip shares some lessons and thoughts after using this converter.
I tested a free and useful converter and feel good about it. It really can save my time to convert a VB project at least 50% of my time.

Background

At codeproject.com, there are some wonderful posts with VB project demos and I got many inspirations. I would like to convert them to C# projects.

So which tool should be used? There are many on the Internet, but I found this code converter from SharpDevelop Team. It can convert an entire VB project to C# project. So I gave it a try and am sharing some lessons & thoughts here.

Installations

Go to this site to get vsix file and save it to your local machine.

Double click this downloaded file and it will automatically install on your machine.

Converting a Simple Project

I would like to use reference [3] as a test. Download it and unzip it into your local folder.

Load it into your Visual Studio 2019. Inside Solution Explorer, select this project name and you will see this context menu:

Image 1

Right click this project name and you will see this context menu:

Image 2

Select convert to C# item and you will get this project converted to C# successfully:

Image 3

Go to the same project folder, find csproj file and open this project. Compile it and you will see it has no errors in building process. You can run it without any problem.

One more project[6] is converted and the source code is attached.

Magic Graphics[7] is a another conversion from VB project. the source code is attached. this project needs some manual fixes after using this converter: mainly type conversion and a ref & out variable at the same time refactoring.

Converting a Complex Project

I tested the project in reference [6] and it ran into many errors in build process.

This solution has two projects. So you need to convert one project at a time.

I have to fix these errors one by one. Also, I need to review the corresponding .vb file to understand the original logic.

Lessons Learned

The first thing is to turn on Option Strict and Option Explicit. This will generate most of type conversion errors and I need to fix them one by one.

Points of Interest

It turns out this tool has challenges in converting VB form designer code. I think manual conversion is required to get a successful conversion.

An online version of converter in reference[2] is very helpful to convert one class.

References

  1. Code Converter (VB - C#)
  2. ICSharpCode Converter
  3. Rubberband Lines
  4. A PictureBox with Zoom, Grid and Rulers
  5. Prepare Visual Basic for Conversion to C#
  6. Resize and Rotate Shapes in GDI+
  7. Magic Graphics

History

  • 27th May, 2022: Initialized this post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)