How Convert VB Project to C# Project [closed]
Asked Answered
C

2

109

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 code, 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

Ciapas answered 4/8, 2014 at 6:39 Comment(6)
This thread should not have been closed with 9719 views and 21452 views for its next linked SO question. This is very common issue and I was googling same matter so finally found my answer here from MattWard by redirecting from the other linked question which is already closed too! Please reopen this topic.Rhizogenic
Weird that this is getting re-open now. Whoever voted re-open should post a comment as to why.Mutism
@Mutism I don't have quite enough rep to vote for reopen again, but I would if I could. This is clearly a popular question for .NET developers. The current answers here are outdated now and closing this leads to more duplicates and spam, not less. Yes, the question technically asks for a tool recommendation, but it's not exactly asking "what IDE is best" or something like that. It's posing a specific programming related problem for which tools and scripts exist to solve.Montcalm
@user1751825: It's asking for a tool recommendation, which is defined to be off-topic.Mutism
In Visual STudio 2022, if you reference a VB.NET class library, you can actually navigate the implemented methods of the library by pressing [F12], then Visual Studio will de-compile it for u to view the code... in C#.Subordinate
Just in case it might be of assistance to someone, I had put one together that is written in VB6 that is free to do nearly anything with... github.com/bhoogter/VB6TocSharpBanderilla
B
130

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#.

Buie answered 4/8, 2014 at 8:34 Comment(12)
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 :)Ciapas
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.Goose
did they revove it from SharpDevelop 5? How come?Drumbeat
@Drumbeat - It was removed because SharpDevelop 5 does not support VB.NET.Buie
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\Microsoft.WebApplication.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.vbprojWheelhorse
am facing the same issue on importing project in SD-4.4 , @OlegSh - you got any leads , is there any other way to do itDonau
I would try adding a condition to the Import that checks it exists or just comment out the import.Buie
Instant CSharp is the best but it costs money.Skulduggery
@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.Visayan
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.Indigenous
@Goose This question is now the highest in the Google search results. How ironic.Tetracycline
give DotPeek a try; it will always export to c#Cerebro
A
4

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.

Anarch answered 4/8, 2014 at 6:57 Comment(1)
Thanks for your answer. I guess I have to convert the project converting files one by one :)Ciapas

© 2022 - 2024 — McMap. All rights reserved.