简体   繁体   English

在同一解决方案中找不到引用项目的类型或名称空间

[英]Type or namespace could not be found for a referenced project in the same solution

I am getting this unbelievably annoying issue in VS 2017. Somehow these kinds of issues are always plaguing me.. 我在VS 2017中遇到了这个令人难以置信的令人讨厌的问题。某种程度上,这些问题一直困扰着我。

I opened up my solution today which contains several projects to find that one was just missing for no reason (it is always there when I open the solution). 我今天打开了我的解决方案,其中包含几个项目,发现一个项目无缘无故丢失(当我打开解决方案时,它总是存在的)。

So I simply re-added the project by right-clicking Solution explorer and adding an existing project - easy. 因此,我只需右键单击“解决方案资源管理器”并添加一个现有项目即可轻松地重新添加该项目。

Now, when I try to run that project ( OrderGetter ), it fails to build with 现在,当我尝试运行该项目( OrderGetter )时,它无法使用

The type or namespace name 'Utilities' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或名称空间名称“ Utilities”(您是否缺少using指令或程序集引用?)

Utilties is another project in my solution: Utilties是我的解决方案中的另一个项目:

在此处输入图片说明

It definitely exists and has always worked in the past. 它肯定存在并且过去一直有效。 Why must this issue come and happen now? 为什么这个问题现在必须发生并发生?

Eveb weirder, The error keeps disappearing from the errors window, but when I try to build I get the popup telling me I have errors, and I have to check the output window to see what is going on. Eveb weirder,错误不断从错误窗口中消失,但是当我尝试构建时,弹出窗口告诉我我有错误,并且我必须检查输出窗口以查看发生了什么。

I have tried the following: 我尝试了以下方法:

  • Clean solution 清洁溶液
  • Clean project 清洁项目
  • Build/Rebuild solution 构建/重建解决方案
  • Build/Rebuild projecct 构建/重建项目
  • Close all tabs, restart VS 关闭所有标签,重启VS
  • Remove/re-add reference 删除/重新添加参考
  • Unload project, delete reference from the csproj file and then re add it in the VS UI before reloading the project 卸载项目,从csproj文件中删除引用,然后在重新加载项目之前将其重新添加到VS UI中
    • Checked that the csproj GUIDs match 检查csproj GUID是否匹配

I can see the following in Solution.sln : 我可以在Solution.sln看到以下内容:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVCQCPage", "MVCQCPage\MVCQCPage.csproj", "{FF699AAD-EA97-4984-9DB2-70F2CA41CA16}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibrary\SharedLibrary.csproj", "{0E6DE04C-97A2-4C18-AB83-098C383DF9C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Identity.SQLite", "..\..\..\..\Downloads\Firefox\Asp.Net.Identity.SQLite-master\Asp.Net.Identity.SQLite-master\AspNet.Identity.SQLite\AspNet.Identity.SQLite.csproj", "{35DAC40A-38D0-43BD-8DCF-34E4061F0A75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Identity.SQLite.EF", "..\..\..\..\Downloads\Firefox\Asp.Net.Identity.SQLite-master\Asp.Net.Identity.SQLite-master\AspNet.Identity.SQLite.EF\AspNet.Identity.SQLite.EF.csproj", "{D34D1279-F264-4A90-B4A5-2AAE4DE5D0D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublicSite", "..\..\..\..\Downloads\Firefox\Asp.Net.Identity.SQLite-master\Asp.Net.Identity.SQLite-master\PublicSite\PublicSite.csproj", "{18D9B36C-50A0-4753-9522-A1C282C70B3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilities", "Utilities\Utilities.csproj", "{4473F366-D894-425D-AFE2-75EC883AC0E7}"
EndProject
Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "Scripts", "Scripts\Scripts.pssproj", "{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TurboTime", "TurboTime\TurboTime.csproj", "{05FFA6B7-8ACE-4FDF-83DB-75FBF7C46E64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TurboTimeConsole", "TurboTimeConsole\TurboTimeConsole.csproj", "{F5B79240-155C-4E8B-B8F7-BFFBC9EFE9EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderGetter", "OrderGetter\OrderGetter.csproj", "{BBD80E29-721A-4423-A21E-4B6C51D153FF}"
EndProject

And in Utilites.csproj I can see that the GUId is Utilites.csproj我可以看到GUId是

<ProjectGuid>{4473F366-D894-425D-AFE2-75EC883AC0E7}</ProjectGuid>

And that OrderGetter.csproj is referencing 那个OrderGetter.csproj正在引用

    <ProjectReference Include="..\Utilities\Utilities.csproj">
  <Project>{4473f366-d894-425d-afe2-75ec883ac0e7}</Project>
  <Name>Utilities</Name>
</ProjectReference>

So the GUIDs are the same except for one being upper case and the other lower case. 因此,GUID相同,除了一个是大写字母,另一个是小写字母。 What does that mean? 这意味着什么?

You can clearly see that the project is definitely being referenced: 您可以清楚地看到该项目绝对被引用:

在此处输入图片说明

Why is this happening? 为什么会这样呢?

If the above does not help, you can open the solution as well as the project files in a text editor and check if the project file have the correct references set. 如果上述方法没有帮助,则可以在文本编辑器中打开解决方案以及项目文件,并检查项目文件是否设置了正确的引用。

Each project has a unique GUID 每个项目都有唯一的GUID

<ProjectGuid>{12D33B77-30A1-4D07-9DA4-8789AF6746F5}</ProjectGuid>

the referencing project uses this GUID along with the path to reference this project: 引用项目使用此GUID以及引用该项目的路径:

<ProjectReference Include="..\Data Binding Demo\C#\databindinglab.csproj">
  <Project>{12D33B77-30A1-4D07-9DA4-8789AF6746F5}</Project>
  <Name>databindinglab</Name>
</ProjectReference>

Check the affected projects and make sure file names and GUIDs match. 检查受影响的项目,并确保文件名和GUID匹配。

If this does not help, remove all references, save and close the project and then add each reference again. 如果这样做没有帮助,请删除所有引用,保存并关闭项目,然后再次添加每个引用。

暂无
暂无

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

相关问题 “找不到类型或命名空间&#39;AjaxControlToolkit&#39;...”的解决方案是什么? - What is the solution for “The Type or namespace 'AjaxControlToolkit' could not be found…”? “无法找到”类型或命名空间“,但引用了程序集,框架全部为4 - “type or namespace could not be found” but assembly is referenced, and frameworks are all 4 找不到类型/名称空间 - Type/ NameSpace could not be found VS 2013.NET4,同一项目,找不到命名空间 - VS 2013. .NET4, same project, Namespace could not be found 生成项目时出现“找不到类型或名称空间”错误 - “The type or namespace could not be found” error while building a project MonoDevelop项目构建失败,并显示“找不到类型或名称空间“ GDK” - MonoDevelop project build fails with 'The type or namespace 'GDK' could not be found 从同一解决方案打开 c# 命名空间,在 f# 中引用项目 - open c# namespace from same solution, referenced project in f# 找不到类型或名称空间名称(相同的.NET Frameworks) - The type or namespace name could not be found (same .NET Frameworks) “引用System.Xml.dll时,无法找到类型或命名空间名称'XmlSerializer'”错误 - “The type or namespace name 'XmlSerializer' could not be found” error when System.Xml.dll is referenced “未找到类型或命名空间名称‘XXXX’”但已被引用 - “The type or namespace name 'XXXX' not found” but already referenced
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM