views:

859

answers:

6

Is there a tool to convert a VB.NET 2005 project to a C# 2008 project. I am trying to convert our project to VS 2008 and mostly port all the vb.NET code in some projects to C# 3.0/3.5.

+1  A: 

Take a look at this.

http://www.developerfusion.com/tools/convert/vb-to-csharp/

Try to google term "convert vb.net project to c# project", you will find a couple of options there.

J.W.
A: 

Telerik has a converter you might want to take a look at.

Joseph
I am looking to convert the whole project. Instead of some files.
Greens
+3  A: 

I had a similar decision to make with a VB.net project. Solution was a compromise, I decided to run with dual VB and C#.

Upgrading VB.NET 2005 to 2008 is easy bit.

Added CSharp and VB folders to App_Code and

<codeSubDirectories>
<add directoryName="CSharp" />
<add directoryName="VB" />
</codeSubDirectories>

to compilation section of web.config

As Kev says, it's not as straight forward as you might expect, and you will likely run into unexpected issues , that make running with dual language support the best solution

I know this doesn't directly answer the question, but it's an alternative approach

Stuart
+1  A: 

There's a tool on CodeProject called GBVB (Goodbye VB) that purports to 'flawlessly' convert VB.NET code to C# code. However the author does add a number of caveats such as the problems with ambiguous code, optional parameters etc.

Another approach could be to use Denis Bauer's Reflector.FileDisassembler .NET Reflector add-in and disassemble the compiled assemblies back to C#.

Handling .aspx/.asmx pages and their code-behind files would probably be a special case because you'd need to manually change the <%@ Page Codebehind="Default.aspx.cs" %> directives to point to the correct source files.

Automatic VB.NET to C# conversion isn't really as straight forward as it initially appears to be. I've been here before and gave up on a fairly large project, there's a lot of fiddling about with specific edge cases where the translation either wouldn't compile or produced unexpected behaviour at runtime. I elected to go for a dual language solution where all new code was written in C# and older VB.NET code was ported gradually over time.

Kev
+1  A: 

You could check out SharpDevelop. It's an open source .NET development environment. SharpDevelop has some code conversion built in.

C-Pound Guru
A: 

Since others have mentioned online conversion tools I've found www.carlosag.net to work the best for my code. Maybe b/c I work other 3rd party API's but it seems like a lot of the other online converter just error out if they hit a line they can't convert.

the empirical programmer
This is also Gr8.
Greens