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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 10, 2012, 7:22 AM
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.
Satyapriya NayakPosted Apr 10, 2012, 12:28 AM
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