Is it possible to have C # and vb.net on the same asp.net site?

Is it possible to have C # and vb.net on the same asp.net site? without separation in class libraries.

+4
source share
6 answers

Try this in the App_Code subfolder to create two new subfolders, one for your C # classes and another for your VB.NET classes. After that, specify these 2 folders in the web.config file in the following section:

<system.web> <compilation debug="true"> <codeSubDirectories> <add directoryName="CSharp"/> <add directoryName="VB"/> </codeSubDirectories> </compilation> 

Or you can create a new project in another language and add a link to it.

+4
source

No - the compiler needs code files in different languages ​​for compilation separately. The C # class library cannot contain VB.NET code, simply because the compiler cannot distinguish which code files are written in which language.

+3
source

If you have a web application project then this is possible.

If you have a website project then this is not possible.

+3
source

At a very theoretical level, this is possible. As some people have noted, you can use different methods to have multiple class libraries in one application, each of which is written in a different programming language. At the end, he imitates the experience of writing a single application in several languages. I would say that most of the time this should be enough.

There is also a small, well-known feature of .NET and the CLR called the "net module". See this blog post for an explanation of network modules and assemblies (and even assemblies with multiple files!).

Having said all this, my first recommendation would be to simply choose one language and stick to it. If this is not an option, having multiple assemblies is a good choice. Using the App_Code trick mentioned by Florim will allow you to store all your files in one project, even if several assemblies on ASP.NET will be created on ASP.NET (you will never see them).

If you have problems with having multiple assemblies, rather than with multiple projects, then it would be helpful to find out what the problem is. ASP.NET projects, one way or another, are almost always compiled into multiple assemblies. There are tricks to avoid this, but they are rarely used (e.g. aspnet_compiler and aspnet_merge).

+1
source

when trying to find out that you cannot (by default) have different languages ​​on the website in the App_Code folder. But for other files outside (App_Code) yes you can.

to have different languages ​​under App_Code, you need the technique mentioned by Florim.

I thank all the guys for their help.

0
source

Unable to try in another language

-1
source

All Articles