1

I looked into:

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

as well as:

http://www.icsharpcode.net/opensource/sd/

but neither does exactly what I want.

EDIT:

The first link translates only the source code (.vb) and does a good job at it. I also need to convert the project.

The second link ... #develop does not handle .Net 4.0 projects.

So, that is why I said that neither does exactly what I want.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
  • We don't know what you want either. – Hans Passant May 24 '10 at 21:01
  • Really? 2 votes to close? Why? – Hamish Grubijan May 24 '10 at 21:04
  • I don't know of any automated type of tool. How big is your project? – Matt Dawdy May 24 '10 at 21:06
  • It has 4 files, 400 lines of code total + app.config file with VB.Net specific stuff as well as the project file itself. It is the only VB.Net project alongside other 20 C# projects and it is an eyesore ... just the fact that it shows errors after clean bothers me. And as always, the guy who wrote this some time ago left ... and it compiles into a mission-critical .exe I do not like depend on mess like that. – Hamish Grubijan May 24 '10 at 21:11
  • 2
    With only 400 lines of code, I'd probably just try to rewrite it. Using the first tool you linked to would get you probably 50% of the way there, and the only difficult part would be the app.config stuff. The project file would probably be simplistic to create since it most likely just references the other 4 code files. Is there another reason you haven't just rewritten it yet? – Matt Dawdy May 24 '10 at 21:17
  • Yes, two reasons: 1) app.config file is VB.Net specific - contains 2) Not sure how to translate this to C#: ' Shortcut files have a .lnk extension shortCut = CType(shell.CreateShortcut(strShortCutDest), IWshRuntimeLibrary.IWshShortcut) – Hamish Grubijan May 24 '10 at 21:40
  • Hamish -- I looked up the Microsoft.VisualBasic.Logging.FileLogTraceListener on MSDN, and it appears you CAN use it from C#. However, if it is just basic logging, then if it were me, I'd drop in log4net and dump the VB stuff. As far as the shortcut files having a .lnk extension, I don't know what you mean. It's probably just my inexperience with VB desktop development (been a LONG time for me!) but that code looks like standard Windows Scripting Host code which almost has to be the same in c# as it is in VB. – Matt Dawdy May 25 '10 at 18:15

1 Answers1

1

Hamish -- I'm pulling out of the comment stream to answer the question directly. There doesn't seem to be a magic program, unfortunately. But the good news for you is that it is a relatively small program (400 lines of code in only 4 files).

So, if it were me, I would

  1. start a new C# project,
  2. add the 4 class files that you have,
  3. run them each through the VB->c# translator you linked to originally,
  4. dump the VB logging stuff and add in log4net
  5. turn the Windows Scripting stuff from VB into C# (I think your problem with this is that the translator above is flipping out on the types of WindowsScripting Host stuff)
  6. Compile and test.

With luck, this will take you a couple of hours. With bad luck, it depends on what the project actually does and that will determine how long.

I wish you good luck.

If you decide to go this route, be liberal about commenting out huge parts of code and compiling and working on eliminating compiling errors first. I'll try to keep an eye out to help you with any other specific questions that I see come across the front page.

Matt Dawdy
  • 19,247
  • 18
  • 66
  • 91