如何从可视化基础项目中删除未使用的类? [英] How do I remove an unused class from a visual basic project?

查看:86
本文介绍了如何从可视化基础项目中删除未使用的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,它开始使用Visual Basic 2017编码,现在是2019年。我在2017年写入了3个类,我不再使用它。当我去删除它们时,它们不会显示在我的项目列表中,而是显示在与主项目所在的目录不同的目录中(目录名称为我的项目)。我没有在程序中引用这些类,但编译器仍然会查找它们并抛出错误,说它无法找到它们。我尝试将它们移动到主程序所在的同一目录中,但这会产生更多问题。现在,我注意到,当我添加一个新的类或方法时,它将它放在我的项目目录中,并且它不会显示在解决方案列表中。问题1,为什么这个新的类代码被放入不同的目录,2,如何从我的解决方案中完全删除旧的代码。它们不在项目列表中,所以我不能像过去那样进行正常删除。编译器还有一个.vb文件,它看起来似乎不在任何地方。我对所有驱动器都进行了全面搜索,但找不到它。该解决方案的目录树是:



C:\ Visual Basic 2017:\\ MyMovies-2019 \ MyMovies-2019



我遇到问题的文件目录是:



C:\ Visual Basic 2017 \ MyMovies-2019 \ MyMovies- 2019年我的项目



我不知道当所有其他.vb文件都在主MyMovies-2019目录中时它们是如何结束的。



我尝试过:



试图通过我的项目列表删除它们但他们没有出现在那里。尝试从我的项目目录中删除并获得编译器错误。现在我有.vb文件,我找不到,所以我可以恢复它。

I have a project which was started coding in Visual Basic 2017 and now in 2019. There are 3 classes that I wrote into the project in 2017 that I no longer use. When I went to remove them they don't show up in the My Project list instead they are in a different directory than the main project is in ( the directory name is 'My Projects'). I do not refer to these classes in the program but the compiler still looks for them and throws an error saying it cant find them. I tried moving them to the same directory as the main program is in but that created more problems. Now, I have noticed as I add a new class or method it puts it in the 'My Projects' directory and it does not show up in the solution list. Questions, 1, why are this new class code being put into a different directory, and 2, how do I remove the old ones entirely from my solution. They are not on the Projects list so I can't do the normal delete as I have done in the past.There is also one .vb file the compiler is looking for that doesn't appear to be anywhere. I've run a full search on all of my drives and can not find it. The directory tree for the solution is:

C:\Visual Basic 2017\MyMovies-2019\MyMovies-2019

directory for the files I have a problem with is:

C:\Visual Basic 2017\MyMovies-2019\MyMovies-2019\My Projects

I have no idea how they ended up there when all other .vb files are in the main MyMovies-2019 directory.

What I have tried:

Tried to delete them through the 'My Projects' list but they don't show up there. Tried deleting from the 'My Projects' directory and get compiler errors. Now I have the .vb file that I can't find so I can recover it.

推荐答案

听起来好像你的实际文件和你的项目设置已经出来了步骤。最简单的方法是创建一个新项目,然后复制所需的源代码。
It sounds as though your actual files and your project settings have become out of step. The simplest thing to do would be to create a new project and just copy over the sources that you need.


请按照MSDN的说明进行操作:删除或删除项目或项目 - SQL Server Microsoft Docs [ ^ ]



Please, follow the instruction from MSDN: Remove or Delete an Item or Project - SQL Server | Microsoft Docs[^]

Quote:

删除项目项目:

To remove a project item:



  1. 在解决方案资源管理器中,选择要删除的项目项目。
  2. 在编辑菜单上,单击删除。
  3. 在确认对话框中,单击删除以从项目中删除该项目。



文件系统上仍存在已删除的项目。因此,您可以将删除的项目添加到其原始解决方案或其他解决方案。


A removed item still exists on the file system. Therefore, you can add a removed item to its original solution or to another solution.







如果你无法找到文件,您可以在左侧窗格中看到它,请转到:




IF you can not locate file and you're able to see it in the left pane, go to:

Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer





如果无法访问上述内容,请按照以下说明操作:视觉工作室提示#8:使用全部显示添加现有文件文件 - 大脑转储 [ ^ ]

然后,您将能够从解决方案资源管理器中删除该文件。 />


最后,您始终可以显示所有文件:解决方案资源管理器不显示文件夹,尽管该文件夹存在于我的本地驱动器(本地副本)Visual Studio - Stack Overflow [ ^ ]



祝你好运!



If above is inaccessible, follow the instruction from: Visual Studio Tip #8: Adding existing files with Show All Files – The Brain Dump[^]
Then you'll be able to remove that files from solution explorer.

Finally, you can always show all files: Solution Explorer doesnt show the folder although the folder is present in my local drive (local copy) Visual studio - Stack Overflow[^]

Good luck!


这篇关于如何从可视化基础项目中删除未使用的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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