Is it possible to have C# and vb.net in the same asp.net website?

后端 未结 6 1601
失恋的感觉
失恋的感觉 2020-12-06 08:11

Is it possible to have C# and vb.net in the same asp.net website? without separating in class libraries.

6条回答
  •  离开以前
    2020-12-06 08:39

    At a very theoretical level it is possible. As some people here have noted, it is possible to use various techniques to have multiple class libraries in the same application, each written in a different programming language. In the end it simulates the experience of writing a single application in multiple languages. I would say that most of the time that should be sufficient.

    There is also a little known feature of .NET and the CLR called a "net module". See this blog post for an explanation on net modules and assemblies (and even multi-file assemblies!).

    Having said all this, my first recommendation would be to just choose one language and stick to it. If that isn't an option, having multiple assemblies is a good choice. Using the App_Code trick mentioned by Florim will allow you to keep all your files in one project, even though multiple assemblies will be created on disk by ASP.NET (you'll never see them though).

    If you have some worries about having multiple assemblies as opposed to multiple projects then it would be helpful to find out what the concern is. ASP.NET projects, one way or another, almost always get compiled into multiple assemblies. There are tricks to avoid that, but they are seldom used (such as the aspnet_compiler and aspnet_merge).

提交回复
热议问题