简体   繁体   English

.NET Intellisense:一个解决方案中的 2 个项目

[英].NET Intellisense: 2 projects in one solution

I have created a solution file consisting of these 2 projects: ProjectA and ProjectB (main).我创建了一个由以下 2 个项目组成的解决方案文件: ProjectAProjectB (主要)。 How can I get Visual Studio's Intellisense to work across the two projects?如何让 Visual Studio 的 Intellisense 在这两个项目中工作?

For example:例如:

ProjectA has ClassA with MethodA . ProjectAClassAMethodA While working on ProjectB , how do I get Intellisense to detect MethodA and any documentation on it without a build/rebuild of ProjectA ?在处理ProjectB ,如何在不构建/重建ProjectA情况下让 Intellisense 检测MethodA及其上的任何文档?

You need to add a Project A as a project reference in Project B using the projects tab of the Add Reference dialog.您需要添加一个项目作为使用Add Reference对话框的项目选项卡项目B的项目引用

This will cause Visual Studio to read Project from the project system rather than the compiled DLL.这将导致 Visual Studio 从项目系统而不是已编译的 DLL 中读取项目。 This offers a number of advantages:这提供了许多优点:

  • You won't need to rebuild it你不需要重建它
  • Visual Studio will realize that there is a dependency and automatically build project A when building project B Visual Studio在构建项目B时会意识到存在依赖并自动构建项目A
  • Editor features like Go to definition will work.转到定义等编辑器功能将起作用。

In the event that you already have a reference (and the Intellisense is still not showing up), this probably means you are referring to a dll already.如果您已经有一个引用(并且 Intellisense 仍未显示),这可能意味着您已经引用了一个 dll。 You will have to remove the reference and add it again via the Add Reference dialog as mentioned above, or it will tell you that it already has that reference.您将必须删除引用并通过上述添加引用对话框再次添加它,否则它会告诉您它已经具有该引用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM