[英]Visual Studio - Intellisense not recognizing namespace in another project within same solution
I have a solution consisting of two projects.我有一个由两个项目组成的解决方案。
The first project is Project.api, while the second is Project.models within C# .NET (webapi) solution.第一个项目是 Project.api,而第二个项目是 C# .NET (webapi) 解决方案中的 Project.models。 I can not get test.models to be recognized when pointing to it via
using test.models;
通过
using test.models;
指向它时,我无法识别using test.models;
at the top of one of my classes.在我的一堂课中名列前茅。
What do I need to do to get the api project to not show red underline under the .models namespace?我需要做什么才能让 api 项目在 .models 命名空间下不显示红色下划线?
I have tried to re assign asp.net version from 4.5.2 to 4.0, and included references to Project.models under Project.api without success.我试图将 asp.net 版本从 4.5.2 重新分配到 4.0,并在 Project.api 下包含对 Project.models 的引用,但没有成功。
How can I get past this intellisense issue?我怎样才能解决这个智能感知问题?
Please see Solution Explorer screenshot.请参阅解决方案资源管理器屏幕截图。 Root namespace renamed.
根命名空间已重命名。
For anyone reading this in 2020, a fix that I've found that has worked for me is cleaning the solution and unloading the projects that have dependencies such as a web API depending on a data project and an application project, then reloading and building each project in the order of dependence such that they build successfully.对于在 2020 年阅读本文的任何人,我发现对我有用的修复程序是清理解决方案并卸载具有依赖项的项目,例如依赖于数据项目和应用程序项目的 Web API,然后重新加载和构建每个按依赖顺序进行项目,以便它们成功构建。
Unloading projects: right click on the project in solution explorer and find "Unload Project"卸载项目:在解决方案资源管理器中右键单击项目并找到“卸载项目”
Reloading Projects: right click on the unloaded project in solution explorer and find "Reload Project"重新加载项目:在解决方案资源管理器中右键单击已卸载的项目并找到“重新加载项目”
so in my case my data project does not depend on any other project so I first reloaded and built that project, next the application project which depends on the data project and finally the web API project which depended on both data and application.所以就我而言,我的数据项目不依赖于任何其他项目,所以我首先重新加载并构建了该项目,然后是依赖于数据项目的应用程序项目,最后是依赖于数据和应用程序的 Web API 项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.