Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting large ASP.NET VB.NET project to C# - incrementally?

Tags:

c#

asp.net

vb.net

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?

like image 405
Joey Avatar asked Sep 18 '08 13:09

Joey


People also ask

Can you convert VB.NET to C#?

Code Converter (VB - C#)Adds context menu items to convert projects/files between VB.NET and C#. Flexible: Convert a small selection, or a whole solution in one go, in either direction.

Can I use VB.NET and C# in same project?

You can not mix vb and c# within the same project - if you notice in visual studio the project files are either . vbproj or . csproj. You can within a solution - have 1 proj in vb and 1 in c#.

Can we use VB class in C# project?

Yes, you can use it. If you compile the VB project to a class library (dll) you can reference that library in your C# project. In order to access the types and their members from the C# project, they must be defined as public.


2 Answers

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.

like image 167
Wayne Avatar answered Oct 14 '22 17:10

Wayne


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.

like image 45
SpoiledTechie.com Avatar answered Oct 14 '22 19:10

SpoiledTechie.com