Introduction
In ASP.NET 2.0 you can use C# and VB.NET web forms together in one web site. But if you want to use classes coded in different languages, Such mixing is not allowed by default settings. However you can configure web site to get this done. This article drill down to achieve this.
Create App_Code and Sub Directories with classes
Create a new web site in VS.NET 2005. Add App_Code folder to it.
Add two class files in App_Code- TestClass1.cs(C# code) and TestClass2.vb(VB Code). Build the application. It will show the following error
To overcome this error add two sub directories(CS,VB) one for C# class and one for VB class
Now when you try to build the application, it shows the following error
Here is the trick - If you have class files written in different languages, create language-specific App_Code subdirectories to contain classes for each language. Add entry to the web.config file for each subdirectory. It is important that the language-specific subdirectory is registered in the web.config otherwise, all files under App_Code will be compiled to a single assembly regardless of the folder they belong.
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="CS"/>
<add directoryName="VB"/>
</codeSubDirectories>
</compilation>
Using multiple languages in the same ASP.NET project is helpful when you're integrating existing code or when you have developers on the project with different skills.