8

Was looking for some approaches to incrementally converting an large existing ASP.NET VB.NET project to C# while still being able to deploy it as a single web application (currently deployed on a weekly basis).

My thoughts were to just create a new C# ASP.NET project and slowly move pages over, but I've never attempted to do this and somehow merge it with another ASP.NET project during deployment.

(Clarification: Large ASP.NET VB.NET projects are absolute dogs in the VS IDE...)

Any thoughts?

3
  • you haven't tagged your question. Commented Sep 18, 2008 at 14:00
  • really? I see 4 tags on the right that I tagged it with when I created the question... c#, asp.net, vb.net, conversion Commented Sep 18, 2008 at 14:15
  • chrissie1: The tags are in the left now (don't know why the change) Commented Sep 18, 2008 at 18:53

10 Answers 10

5

Start with the business logic and work your way out to the pages. Encapsulate everything you can into C# libraries that you can add as references to the VB.NET site.

Once you've got all of your backend ported over and tested, you can start doing individual pages, though I would suggest that you not roll out until you've completed all of the conversion.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That's pretty much the approach we've been taking up until now. But since we do weekly releases to production, I'm not sure the "wait until they're all done before deploying" part would work for us too well.
4

You are allowed to keep your App_Code Directory with both VB code and C# code in it. So effectively, you could do it very slowly when you have the spare time to convert it.

I currently have both VB.Net and C# code in my App_Code directory and on my spare time I convert to VB.Net code or anytime I have to go back to a page with VB.Net and mess with it I convert it to C#.

Easy Peasy and Microsoft made it even nicer when they allowed you to have both VB.NET and C# on the same app. That was one of the best ideas they could have implemented in the entire app making process.

If you want to add both code directories in your one directory add this to your Web.config

<compilation>
<codeSubDirectories>
    <add directoryName="VB_Code"/>
    <add directoryName="CS_Code"/>
</codeSubDirectories>
</compilation>

And then add a folder named VB_Code and another folder named CS_Code in your App_Code directory. Then throw all you vb/C# code in your folders and your good.

Comments

3

A like for like port I take it? I don't really see the point and what you will gain for all the effort. Maybe write any new features or refactor sluggish/bad existing logic/service layers into c# but as for web pages I don't see the 80/20 benefit.

3 Comments

Right, we are refactoring and moving code down to presenters, services, etc. But if you've ever worked in the VS IDE with a large ASP.NET VB.NET project before, you know how much VB.NET kills the IDE. So we're looking for a short-term solution to get past the VB.NET impediment.
Hi, no I have never worked with a vb.net solution, but I cant see how a rewrite to c# is a short-term solution if the site is large.
Thanks for the response. I'ma actually not talking about a rewrite. I can use SharpDevelop for the actual conversion one page at a time. I was more wondering about the incremental part as it relates to merging 2 asp.net web projects to be deployed as one. Thanks!
1

Keep the old stuff in VB. All new stuff in C#. The transistion might be slow but you will not loss time. On free time, change stuff in C#.

Comments

1

I did this with one project by doing the following:

  1. Create a C# class library
  2. Reference the C# class library from the VB web application
  3. Create the code behind class in the C# library
  4. Update the "Inherits" property in the aspx/ascx file to reference the C# class (this file still exists in the original VB project)

It worked somewhat ok; It's a bit of a pain sometimes in that you now have to browse across multiple projects to view a single page/control, but it did let me do what you are wanting to do.

Comments

1

You can simply make a new c# class library project in the solution. recode a few classes at a time in here and then replace the vb classes in the main project.

but to be honest I would agree I don't see the benefit unless your trying to learn c# or just really don't like vb or just bored.

Comments

1

I've had success pulling in dlls of vb projects with Reflector(it's free) and viewing the code as C#. Local variables don't always translate but you can compare the translation and refactor things as you go.

Comments

1

try #Develop. I think this the best way to convert ANY .net supported to any .net suppported languages.

Other tools convert only the code but this converts the whole project.

Comments

0

It can be done. Well I hope it can be done as I am doing this bit by bit on a legacy ASP.net application. You could just change over 1 Webform at a time. Where you may struggle is that I can't seem to have mixed languages in the app code folder as they are compiled together.

Comments

0

If you've got $179 you're done.

Of course there are freeware converters available as well.

1 Comment

Thanks, but the actual conversion itself is not really the issue. Guess my question title was not all that clear. It's the "incremental" part of the conversion that relates to merging/deployment of the web project that was really what I was wondering about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.