Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

ASP.NET: Use C Sharp and VB.NET in the same project

From Wiki

Jump to: navigation, search

Summary: Use C# and VB.NET classes in the same ASP.NET application

Whilst it isn't ideal to both mix C# and VB.NET languages in the same ASP.NET project, it is possible. The code still has to be separated and it can't be mixed at page level but you can create a class in each language and then use and reference them both from any page.

To do this, you'll need to follow a few simple steps.

Step 1

Create an App_Code folder if it doesn't already exist. Then, inside this folder create two other folders to hold each language type. For example,

  1. App_Code
  2.   vbcode
  3.   cscode

Step 2

Edit your web.config file and make sure the following section is added:

  1. <system.web>  
  2.         <compilation>  
  3.             <codeSubDirectories>  
  4.                 <add directoryName="vbcode"/>  
  5.                 <add directoryName="cscode"/>  
  6.             </codeSubDirectories>  
  7.         </compilation>  
  8. </system.web>

Add each class to the relevant folder and you're done! You can now reference any of the classes in the standard manner and ASP.NET will do all of the compilation automatically for you.


This Hack is part of the ASP.NET Hacks collection

462 Rating: 3.8/5 (5 votes cast)