混合VB.Net和C#code在一个ASP.Net网站项目? [英] Mixing VB.Net and C# Code in an ASP.Net Web Site project?

查看:335
本文介绍了混合VB.Net和C#code在一个ASP.Net网站项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题相当旧的,经常打听,我这里有类似的问题,但我的问题是更具体一点。

The question quite an older and often asked around, i have similar questions here but my question is a bit more specific.

Q1。它是合法的混合C#和VB.Net code在ASP.Net网站?将它的工作或没有?如果一切正常,可能怎么做?任何样品将是不错的。

Q1. Is it legal to mix C# and VB.Net code in ASP.Net Web site? Will it work or not? If it works how it may be done? Any sample will be good.

Q2。如果有混合C#中的任何后果和VB.Net code,那么请你分忧为好。

Q2. If there are any repercussions of mixing C# and VB.Net code then please do share those as well.

我有一个Web项目,是在VB.Net codeD。我的工作项目的一个模块。 ,我想在C#code。我不能整个项目转换为C#,因为我不是唯一的一个项目工作。不过,我打算建立模块,我想有一个内置的C#。

I have a web project that is coded in VB.Net. I am working on one module of the project. and i want to code in C#. I cant convert the whole project to C# because i am not the only one working on the project. However, the module i intend to build , i want to have that built in C#.

我听说,在Web项目的情况下,如果我们在VB.net C#和部分code部分则有编译项目到DLL问题。真的吗?如果是的话那么该如何解决。

I have heard that in case of web projects, if we code part in C# and part in VB.net then there are problems compiling the project to a dll. Is that true? if yes then what is the solution.

另外,如果我建立一个动态链接库中的.Net然后我可以混合使用C#和Vb.Net code?

Also, if i am building a dynamic link library in .Net then can i mix C# and Vb.Net code?

推荐答案

从<一个href=\"http://msdn.microsoft.com/en-us/library/t990ks23.aspx\">http://msdn.microsoft.com/en-us/library/t990ks23.aspx:

在APP_ $ C $文件夹C 多种编程语言

Multiple Programming Languages in the App_Code Folder

由于在APP_ code文件夹中的源$ C ​​$ C编译成一个单一的组件,在APP_ code文件夹中的所有文件必须在相同的编程语言。例如,APP_ code文件夹不能包括Visual Basic和C#源$ C ​​$ C。

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

不过,你可以配置你的Web应用程序来对待APP_ code文件夹作为单独的编译单位的子文件夹。然后,每个文件夹可包含在不同的编程语言源$ C ​​$ C。配置是通过建立在Web.config文件中的编译元素的codeSubDirectories元素,并增加了一个子文件夹引用中指定。下面的例子说明了如何配置名为VB code和CS code子编译成不同的组件:

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:

<compilation debug="false">
    <codeSubDirectories>
        <add directoryName="VBCode" />
        <add directoryName="CSCode" />
    </codeSubDirectories>
</compilation>

到VB code和CS code子文件夹的引用并不需要包括什么编程语言都包含在子文件夹中的任何信息。作为与APP_ code文件夹本身中,ASP.NET推断编译器基于在该子文件夹中的文件的使用。

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.

这篇关于混合VB.Net和C#code在一个ASP.Net网站项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆