【问题标题】:Can't add C# class in visual studio 2019 anymore - Won't link to main file无法再在 Visual Studio 2019 中添加 C# 类 - 不会链接到主文件
【发布时间】:2021-08-15 18:33:16
【问题描述】:

所以我是 C# 和 Vs Studio 的新手。我通过添加新课程和测试我能做什么来学习它。但是,今天似乎无论我做什么,当我创建一个新类时,它都不会链接到主文件。

例如,我将转到顶部的工具栏并导航到Project -> Add New Item -> Visual C# Class

我注意到我不再像以前那样在此窗口中选择命名文件

我目前有工作类,从我上次这样做并尝试在项目中创建一个新文件并在更改类名称时复制/粘贴所有代码,仍然没有工作。

不知道发生了什么,因为我按照 YouTube 教程点击点击,但它仍然不起作用。

以下是我的 VS 工作室的统计数据,自从我上次使用它和上次使用它以来我没有改变,创建一个 c# 类没有这些问题。

Microsoft Visual Studio Community 2019
Version 16.9.4
VisualStudio.16.Release/16.9.4+31205.134
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools 2019   16.9.693.2781
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.9.693.2781
Azure App Service Tools v3.0.0

C# Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   5.9.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

TypeScript Tools   16.0.30201.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

【问题讨论】:

  • 尝试修复VS或重新安装它...或重新启动你的电脑:)
  • 好的,我现在要做演示,我将重新启动而不是重新安装并让你知道。谢谢顺便说一句

标签: c# asp.net .net visual-studio


【解决方案1】:

您的解决方案资源管理器位于“文件夹视图”中 - 它在该视图中的行为有所不同。要切换回常规视图,请单击解决方案资源管理器中的“在解决方案和视图之间切换”图标(带圆圈),然后双击您的解决方案文件 (.sln):

回到解决方案视图后,您应该能够右键单击并添加项目以再次添加类文件,并在创建之前选择其名称。

【讨论】:

  • 谢谢蒂莫西,我已将此解决方案加入书签,以备下次发生这种情况时使用。我实际上已卸载/重新安装,这也起到了作用
  • @matt_3773,如果您从 Visual Studio 中的“打开本地文件夹”而不是“打开项目或解决方案”开始,就会发生这种情况。
猜你喜欢
  • 2021-01-20
  • 2019-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多