Hi friends,
I want to know that Is it possible to placed the source code files of different languages inside the App_Code folder in ASP.NET? How it is possible please explain?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 9, 2012, 8:28 PM EDT
Yes but you need to create two subfolders inside the App_Code and then add both C# and VB.NET in the respective subfolders. You also have to add configuration settings in the web.config for this to work.
Multiple Programming Languages in the App_Code Folder
Because the source code in the App_Code folder is compiled into a single assembly, all the files in the App_Code folder must be in the same programming language. For example, the App_Code folder cannot include source code in both Visual Basic and C#.
However, you can configure your Web application to treat subfolders of the App_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 subfolders named VBCode and CSCode to compile into separate assemblies:
The references to the VBCode and CSCode subfolders do not need to include any information about what programming language is contained in the subfolder. As with the App_Code folder itself, ASP.NET infers the compiler to use based on the files in the subfolder.
Refer
http://msdn.microsoft.com/en-us/library/t990ks23%28v=vs.80%29.aspx
Thanks
SenthilkumarRank #387 · 6.5K reputationPosted Apr 10, 2012, 3:22 AM EDT
If you add the C# and VB files altogether in app_code, it will not be compatible with each other and you will get the compile time error. It assume whatever you select during the application time.
but C# allows to have those different languages altogether in app_code.
For example,
you need to create the two folders in app_code
Add the two folders called VB and C#.
Now you need to add the appropriate language into the appropriate folder.
Now it will identify and apply matching compiler to generate the IL.
Hope this will help you to understand.