开发者

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

Is it possible to 开发者_如何学Chave C# and vb.net in the same asp.net website? without separating in class libraries.


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

<system.web>

<compilation debug="true">

<codeSubDirectories>

<add directoryName="CSharp"/>

<add directoryName="VB"/>

</codeSubDirectories>

</compilation>

Or you can create new project in other language and add referenc to it.


No - the compiler needs code files in different languages to be compiled separately. A C# class library cannot contain VB.NET code, simply because the compiler can't distinguish which code files are written in which language.


If you have a Web Application project, then it's possible.

If you have a Web Site project, then it's not possible.


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).


when tried I found out that you can't (by default) have different languages in a website under App_Code folder.but for other files outside (App_Code) yes you can.

to be able to have different languages under App_Code you need the technique mentioned by Florim.

thank you all guys for help.


It is not posible try in different language

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜