简体   繁体   English

ASP.NET Web 应用程序项目仅显示 VB 选项,而不显示 C#

[英]ASP.NET Web Application Project only shows VB options, not C#

I'm working on a project and I'm fairly new to ASP (not to C#).我正在做一个项目,我对 ASP(而不是 C#)相当陌生。

We have a solution for a whole web application consisting of several projects and I want to add a couple of ASP WebForms to one of the projects.我们有一个由多个项目组成的整个 Web 应用程序的解决方案,我想向其中一个项目添加几个 ASP WebForms。 However, when I right click on the folder of the project and select Add element, it only shows me VB options.但是,当我右键单击项目的文件夹并选择添加元素时,它只显示 VB 选项。

仅显示 VB 选项

But if I try to add other project to the solution, then all the other options are displayed.但是,如果我尝试将其他项目添加到解决方案中,则会显示所有其他选项。

其他选项,yayyy

The project in which I'm trying to add new Web Forms is entirely written in C#, so I don't know well what's happening back there.我尝试添加新 Web 窗体的项目完全是用 C# 编写的,所以我不太清楚那里发生了什么。 I cannot stop thinking it might a dumb mistake I'm making.我无法停止认为这可能是我犯的一个愚蠢的错误。 I'm working under Visual Studio 2017 and .NET Framework 4.7.2.我在 Visual Studio 2017 和 .NET Framework 4.7.2 下工作。 It is there some kind of requirement I'm missing?我缺少某种要求吗?

Thanks in advance for your time and sorry if it's something simpler, but I really don't know what's going on here.提前感谢您的时间,如果它更简单,我很抱歉,但我真的不知道这里发生了什么。

While you're figuring it out, if you need to press on and get some work done just copypaste another file that is already in the solution, and is of the type you require, then change its contents.在您弄清楚时,如果您需要继续完成一些工作,只需复制粘贴解决方案中已有的另一个文件,并且是您需要的类型,然后更改其内容。 This can usually be a time saver anyway, as the "new product" form isn't so hugely different from the "new user" form, just a different bunch of labels and textboxes..无论如何,这通常可以节省时间,因为“新产品”表单与“新用户”表单没有太大区别,只是一堆不同的标签和文本框。

There is nothing magical about the "add new item" dialog, it just adds files with pre filled templated content. “添加新项目”对话框没有什么神奇之处,它只是添加带有预填充模板内容的文件。 For a cs class (for example) that's a file that basically has a detected namespace and the name you specified in the add dialog.对于 cs 类(例如),它是一个基本上具有检测到的命名空间和您在添加对话框中指定的名称的文件。 You could even add a VB file of the type you want and then change the contents and name of the file to be right for C# - it would essentially be adding a couple of curly brackets and changing the case of Namespace and Class (and maybe changing Imports to using)您甚至可以添加所需类型的 VB 文件,然后将文件的内容和名称更改为适合 C# - 它本质上是添加几个大括号并更改命名空间和类的大小写(并且可能更改导入使用)

You cannot mix languages in the same assembly in .Net.你不能在 .Net 的同一个程序集中混合语言。 Create another assembly you can put your C# code in there and use it in the VB.Net project.创建另一个程序集,您可以将 C# 代码放入其中并在 VB.Net 项目中使用它。

Or use VB.Net it's not that bad.或者使用 VB.Net 也不错。

As noted, this looks like that one application was created as a vb.net application.如前所述,这看起来像是将一个应用程序创建为 vb.net 应用程序。

You can freely consume say c# code (assemblies) in a vb.net project.您可以在 vb.net 项目中自由使用 C# 代码(程序集)。 And of course you can do the reverse.当然你也可以反过来。

However, for a given project created?但是,对于给定的项目创建? You can't at the IDE level mix vb.net and c# code modules and general writing of code between c# and vb.net.您不能在 IDE 级别混合 vb.net 和 c# 代码模块以及 c# 和 vb.net 之间的一般代码编写。

However, as in your example, you can certainly "include" multiple mixes of vb.net and c# projects into one same project.但是,在您的示例中,您当然可以将 vb.net 和 c# 项目的多个组合“包含”到同一个项目中。 However, each part and section will still be limited to the chosen language used to build that application.但是,每个部分和部分仍将限于用于构建该应用程序的所选语言。 So mixing is allowed at the project level - but not below that level.所以在项目级别允许混合 - 但不能低于该级别。

So, it looks to be that project was created and developed with vb.net.因此,看起来该项目是使用 vb.net 创建和开发的。 You can't really change that unless you create a new project as c#, and then pull in all the forms, code etc. and re-factor the vb.net to c#.除非您创建一个新项目作为 c#,然后拉入所有表单、代码等并将 vb.net 重构为 c#,否则您无法真正更改它。

So your practical project language choice is really limited to the project level.因此,您实际的项目语言选择实际上仅限于项目级别。 Multiple projects of different languages can be included overall, but each part will remain in its given language choice.可以整体包含不同语言的多个项目,但每个部分将保留其给定的语言选择。 The fact that you can do this in .net is amazing enough, but that language choice is really set in stone at the project level.您可以在 .net 中执行此操作这一事实已足够惊人,但在项目级别,语言选择确实是一成不变的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在ASP.NET C#Web应用程序中使用ASP.NET VB页面 - How to use asp.net vb pages in asp.net c# web application 在ASP.Net Web站点项目中混合使用VB.Net和C#代码? - Mixing VB.Net and C# Code in an ASP.Net Web Site project? C# 中的 ASP.NET Core web 应用程序和 VB.net 中的 windows 应用程序组合 - ASP.NET Core web app in C# and windows application in VB.net combination 在C#类中使用同一ASP.NET网站项目中的VB类 - Using a VB class from the same ASP.NET web site project in a C# class 将具有C#和VB的ASP.NET网站转换为Web应用程序 - Converting an ASP.NET Website that has C# and VB to a Web Application vb.net asp.net webforms application> c#asp.net mvc razor应用程序 - vb.net asp.net webforms application > c# asp.net mvc razor application 如何在同一个ASP.NET Web窗体应用程序中使用c#和vb.net代码? - How can I have c# and vb.net code behinds in the same ASP.NET Web Forms application? ASP.NET Web项目(C#)是否有按需编译选项? - Is there a compile on demand option for an ASP.NET Web Project (C#)? 如何在C#应用程序项目(无Asp.net)上序列化为json? - How to serialize to json on C# application project (no Asp.net)? 在 ASP.NET C# web 应用程序中发送带有附件的电子邮件 - Sending email with attachment in ASP.NET C# web Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM