views:

54

answers:

3

I've been converting all kinds of other things, classes, interfaces, ASP.NET MVC apps, and WPF applications, but I am stumped as to how to convert a windows forms application, as the whole structure seems to be different. Does anyone have any advice on how to tackle this problem?

I see essentially that you have two files, Form1.cs and Form1.Designer.cs. Literally translating them from C# to VB doesn't work because of some intricacies or other of how Visual Basic works. I think you /might/ be able to convert Form1.cs in this way, as it's just a constructor plus event handlers, but the designer contains the references to the controls etc. and I am not sure how to go about doing that.

I am using Visual Studio 2010 Beta 2.

A: 

Redgate.NET Reflector does a great job.

the_ajp
A: 

The two files each contain a part of the Form1 class, in the form of partial classes. As partial classes are also supported in VB.Net, I don't see a problem here.

The designer file contains all of the code generated by the windows forms designer, the Form1.cs file is the place where all custom code goes (event handling, etc).

So after converting both files you should check if all references made to controls in the Forms1.cs file are available in the designer.cs file.

Gerrie Schenck
+1  A: 

My approach would be to create a new form in VB do add some forms and add events and look at the VB generated from there you will be able to see how each element [control/event/propertyset] is done in both C# and VB. From there it should be trival to conver from c# to VB.net. This would give me more confidance the designer could cope with the converted class as well as the runtime.

David Waters
This is pretty much what I have done, and although I can't test it yet (as neither the C# nor VB projects compile... it's part of an exercise for students to fill in the missing code and fix it) it looks promising. It was easier than it looked.
SLC