[英]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: 我尝试了以下方法:
csproj
file and then re add it in the VS UI before reloading the project csproj
文件中删除引用,然后在重新加载项目之前将其重新添加到VS UI中
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.