Having two classes made up of different languages in the /App_Code folder (as shown here) causes
an error to be thrown. It is impossible for the assigned compiler to work with two different languages.
Therefore, in order to be able to work with multiple languages in your /App_Code folder, you must
make some changes to the folder structure and to the web.config file.
The first step is to add two new subfolders to the /App_Code folder—a /VB folder and a /CS folder.
This gives you the following folder structure:
/App_Code
/VB
Add.vb
/CS
Subtract.cs
This still won’t correctly compile these class files into separate assemblies, at least not until you make
some additions to the web.config file. Most likely, you don’t have a web.config file in your solution
at this moment, so add one through the Solution Explorer. After it is added, change the <compilation>
node so that it is structured as shown in Listing 3-17.
Listing 3-17: Structuring the web.config file so that classes in the /App_Code folder
can use different languages
<compilation>
<codeSubDirectories>
<add directoryName=”VB”></add>
<add directoryName=”CS”></add>
</codeSubDirectories>
</compilation>
Now that this is in place in your web.config file, you can work with each of the classes in your ASP.NET
pages. Also, any C# class placed in the CS folder is now automatically compiled just like any of the classes
placed in the VB folder. Because you can add these directories in the web.config file, you are not required
to name them VB and CS as we did; you can use whatever name tickles your fancy.
an error to be thrown. It is impossible for the assigned compiler to work with two different languages.
Therefore, in order to be able to work with multiple languages in your /App_Code folder, you must
make some changes to the folder structure and to the web.config file.
The first step is to add two new subfolders to the /App_Code folder—a /VB folder and a /CS folder.
This gives you the following folder structure:
/App_Code
/VB
Add.vb
/CS
Subtract.cs
This still won’t correctly compile these class files into separate assemblies, at least not until you make
some additions to the web.config file. Most likely, you don’t have a web.config file in your solution
at this moment, so add one through the Solution Explorer. After it is added, change the <compilation>
node so that it is structured as shown in Listing 3-17.
Listing 3-17: Structuring the web.config file so that classes in the /App_Code folder
can use different languages
<compilation>
<codeSubDirectories>
<add directoryName=”VB”></add>
<add directoryName=”CS”></add>
</codeSubDirectories>
</compilation>
Now that this is in place in your web.config file, you can work with each of the classes in your ASP.NET
pages. Also, any C# class placed in the CS folder is now automatically compiled just like any of the classes
placed in the VB folder. Because you can add these directories in the web.config file, you are not required
to name them VB and CS as we did; you can use whatever name tickles your fancy.