我有一个ASP.NET网站项目,现在已经转换为Web应用程序。我将App_Code文件夹中分别包含VB和CS的子目录重命名为Old_App_Code文件夹。现在C#代码无法编译,语法未被识别,错误列表中显示了数百个错误。
我知道在网站项目中可以同时使用多种语言,但是如何在Web应用程序项目中同时编译两种语言?或者我必须将所有的C#代码转换为VB代码吗?
要同时运行C#和VB,您可以对web.config进行一些更改,例如:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="%ASSEMBLY_VERSION%"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="%ASSEMBLY_VERSION%"/>
</compiler>
</compilers>
并且
<compilation debug="true" defaultLanguage="VB">
<codeSubDirectories>
<add directoryName="CS_Code"/>
</codeSubDirectories>
</compilation>