Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Is really I can use Multiple Programming Language in Code Folder (In 2.0)?

The Code folder is not explicitly marked as containing files written in any one programming language. Instead, the ASP.NET infers which compiler to invoke for the Code folder based on the files it contains. If the Code folder contains .vb files, ASP.NET uses the Visual Basic compiler; if it contains .cs files, ASP.NET uses the C# compiler, and so on.

 

If the Code folder contains only files where the programming language is ambiguous, such as a .wsdl file, ASP.NET uses the default compiler for Web sites.

 

Multiple Programming Languages in the Code Folder:

Because the source code in the Code folder is compiled into a single assembly, all the files in the Code folder must be in the same programming language. For example, the Code folder cannot include source code in both Visual Basic .NET and C#.

 

However, you can configure your Web site to treat subfolders of the Code folder as separate compilable units. Each folder can then contain source code in a different programming language. The configuration is specified by creating a <codeSubDirectories> element in the <compilation> element of the Web.config file and adding a reference to the subfolder. The following example illustrates how you would configure the subfolders named VBCode, CSCode as a separate compilable unit: (VBCode, CSCode are sub folders under Code folder)

 

<compilation debug="false">

         <codeSubDirectories>

               <add directoryName="VBCode" />

               <add directoryName="CSCode" />

         </codeSubDirectories>

</compilation>

 

 

Note that the reference to the VBCode or CSCode subfolders does not include any information about what programming language is contained in the subfolder. As with the Code folder itself, ASP.NET infers the compiler to use based on the files in the subfolder. As Name resolution sake I had given names as VBCode and CSCode, but really you can have code what ever the language you want!

 For Begginers on Code Folder feature, Andrew Article helps you

 

No Comments