Can you convert a VB projecto c# ?? RRS feed

  • Question

  • Just getting going with Blend 4 in our team.

    It appears that some of us chose c# as the default language, some chose VB.

    now when when we try and import data from a c# project to a VB one, not surprisingly it fails.

    The VB version of our prototype is the most advanced, but we want to convert it back to C#. Is this possible? I can't see any obvious way to do it but I'm hoping you can. If not, could you EXPORT the screens from the VB project and IMPORT them in to the C# one? again can't see how to do this.

    Any help much appreciated.

    Tuesday, January 25, 2011 5:29 PM

All replies

  • I don't believe there is a way to convert VB to C#....when you create the XAML files, although the XAML is the same the behind the scenes coding is very different...you could probably manually do it...but that would take forever...

    You could try here...although I have no idea if it works.



    John Wildes | Senior Enterprise Architect | United Airlines | Desktop Engineering
    Tuesday, January 25, 2011 6:49 PM
  • Hi BW68,

    I read your question and found this is of major interest. So I thought about and simply tried the following. I tested it only in debug mode but in debug mode it works!

    I created two projects:

    1) A C# Silverlight project.

    2) A VB Silverlight project.

    The C# project simply has one single button.

    To the VB project I added another UserControl named "UserControlVB". To the VB project I added a ChildWindow. UserControlVB contains a single Button which create a new instance of the ChildWindow and then shows the ChildWindow when on the click event.

    I build each project.

    Then I went over to the c' project in VS2010. Select the project, right click -> add -> existing item and naviagted to the VB project in the file explorer, selected the VB project and added this "as a link".

    Next in the C# project I added a reference to the dll of the VB project which is located in the Release folder of the VB solution. In MainPage.xaml.cs I added a using statement to use (in vb it would be import) the VB dll.

    I built the C# project.

    Then in the click event handler of the Button in the C# project I can call the VB UserControl with the follwing line of code:

      private void btCS1_Click(object sender, RoutedEventArgs e)
       UserControlWithVB vbUC = new UserControlWithVB();

    As a result, the UserControlVB appears with the Button on it and with a click on that Button (which is VB) I can show the ChildWindow (which is VB) from my C# project.

    As I mentioned, in debug mode it works fine.

    I am not sure if this answers your question because you ask for a translation of VB to C#. But maybe you could use the technique described to get your VB project parts working inside your C# projects.


    Best regards,


    Wednesday, January 26, 2011 8:15 AM
  • Thanks for the advice.

    We managed to resolve it by creating a new blank c# project, naming the screens exactly the same and carfeully 'cutting & pasting' the screens from the VB project to the c# one!

    It worked fine with minimal issues and we are up and running correctly with a our project as a c# one now.

    Thursday, January 27, 2011 4:41 PM