Using Component (Component Development Language) in ASP.Net: Part 2


Here is Part 1

To mix different language components in App_Code folder we don't do anything special, just as long as all the components in the App_Code folder are written in the same language. For example, if we use Visual Basic.NET to create all your components, then the ASP.NET Framework automatically infers the language of your components and everything just works.

However, if we mix components written in more than one language in the App_Code folder for example, Visual Basic.NET, and C#.Net then we must perform some extra steps. First, we need to place components written in different languages in different subfolders. We can name the subfolders anything we want. The point is to not mix different language components in the same folder. And now we need to modify your web configuration file to recognize the different subfolders. For example, if we create two subfolders in the App_Code folder named VBCode and CSCode, then we can use the web configuration file as given below.

<?xml version="1.0"?>
<add directoryName="VBCode" />
<add directoryName="CSCode" />

When the contents of the App_Code folder are compiled, two assemblies are created: one that corresponds to the VBCode folder and one that corresponds to the CSCode folder. Notice that we don't need to indicate the language used for each folder the ASP.NET Framework infers the language for us. There is nothing wrong with mixing components written in different languages in the same ASP.NET page. After a component is compiled, the .NET Framework treats VB.NET and C# components in the same way.

Note: Continue in Next Part.


Up Next
    Ebook Download
    View all
    View all