简体   繁体   English

错误“找不到类型或命名空间‘MyType’(或者您是否缺少程序集引用?)”

[英]Error "The type or namespace 'MyType' could not be found (or are you missing an assembly reference?)"

I've been getting an error "The type or namespace 'MyType' could not be found (or are you missing an assembly reference?)" , even though the namespace that 'MyType' lives in is added in the references.我一直收到错误"The type or namespace 'MyType' could not be found (or are you missing an assembly reference?)" ,即使在引用中添加了‘MyType’所在的命名空间。 What is really weird is that when I try to run the solution, it does run with no problem (however I am suspecting it causes some other issues).真正奇怪的是,当我尝试运行该解决方案时,它确实运行没有问题(但我怀疑它会导致其他一些问题)。 I tried rebuilding the solution, rebuilding only the project with the namespace that this type is part of, and I also tried all the stuff mentioned here: "Are you missing an assembly reference?"我尝试重建解决方案,仅重建具有此类型所属的命名空间的项目,并且我还尝试了此处提到的所有内容: “您是否缺少程序集引用?” compile error - Visual Studio I'm not sure what is going on. 编译错误 - Visual Studio我不确定发生了什么。 I thought it might have been a csproj file related issue, but the csproj file looks fine I guess:我认为这可能是与 csproj 文件相关的问题,但我猜 csproj 文件看起来不错:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

</Project>

I am a bit lost, does anyone know what this can be related to?我有点迷路,有谁知道这可能与什么有关? Thank you in advance!先感谢您!

Like I mentioned in the comment above, I finally resolved the issue.就像我在上面的评论中提到的,我终于解决了这个问题。 I clicked "Add Reference" on the project that had errors in it, I saw the appropriate reference, as mentioned before.我在其中有错误的项目上单击“添加参考”,我看到了适当的参考,如前所述。 But even though I saw it I decided to click "Browse" in the references window and add it again.但即使我看到了它,我还是决定在参考文献 window 中单击“浏览”并重新添加它。 When I browsed to the csproj file that needed to be added as a reference, it had the wrong name.当我浏览到需要作为参考添加的 csproj 文件时,它的名称有误。 So the thing is, some time ago I changed the name of the csproj file of the project that had 'MyType' in it.所以事情是,前段时间我更改了其中包含“MyType”的项目的 csproj 文件的名称。 Even though the project had the new name in my File Explorer and Solution Explorer, when I browsed to it from the references window in VS2019, it had the wrong name, so 'MyType' couldn't be found, because VS was looking for a project that had the wrong name and didn't exist anymore.尽管该项目在我的文件资源管理器和解决方案资源管理器中具有新名称,但当我从 VS2019 中的引用 window 浏览到它时,它的名称错误,因此找不到“MyType”,因为 VS 正在寻找一个名称错误且不再存在的项目。 Hopefully that'll help someone希望这会帮助别人

PS: Another thing that I've notices and wanted to mention is that the project with 'MyType' was the git changes someone else pushed and I pulled. PS:我注意到并想提及的另一件事是,带有“MyType”的项目是 git 更改,其他人推送,我拉取。 But I noticed after I pulled the changes, this project had a + icon instead of the lock icon, when I hovered over it, it said "Pending Add", which means, even though I pulled the changes, this change wasn't checked in on my end.但是我注意到在我拉动更改后,这个项目有一个 + 图标而不是锁定图标,当我将鼠标悬停在它上面时,它显示“Pending Add”,这意味着,即使我拉动了更改,这个更改也没有被检查在我这边。 So I closed VS, opened it back up and re-pulled.所以我关闭了 VS,重新打开它并重新拉动。

暂无
暂无

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

相关问题 我收到错误消息“在全局名称空间中找不到类型或名称空间名称&#39;CS&#39;(您是否缺少程序集引用?)” - I'm getting error “The type or namespace name 'CS' could not be found in the global namespace (are you missing an assembly reference?)” 找不到类型或命名空间“系统”。 您是否缺少程序集参考? - The type or namespace 'system' could not be found. Are you missing an assembly reference? “找不到类型或名称空间名称。 您是否缺少程序集参考?” Unity中的错误 - “The type or namespace name could not be found. Are you missing assembly reference ?” Error in Unity 错误 CS0246:找不到类型或命名空间名称“Npgsql”(您是否缺少 using 指令或程序集引用?) - error CS0246: The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?) 错误1找不到类型或名称空间名称*(您是否缺少using指令或程序集引用?) - Error 1 The type or namespace name * could not be found (are you missing a using directive or an assembly reference?) &#39;错误32找不到类型或命名空间名称&#39;ConnectionHelper&#39;(您是否缺少using指令或程序集引用?)&#39; - 'Error 32 The type or namespace name 'ConnectionHelper' could not be found (are you missing a using directive or an assembly reference?)' 错误CS0246找不到类型或名称空间名称“ Windows”(是否缺少using指令或程序集引用?) - Error CS0246 The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?) 错误:找不到类型或命名空间名称“Application1”(您是否缺少 using 指令或程序集引用?) - Error: The type or namespace name 'Application1' could not be found (are you missing a using directive or an assembly reference?) Unity 2019 错误找不到类型或命名空间名称“NotSupportedException”(您是否缺少 using 指令或程序集引用?) - Unity 2019 error The type or namespace name 'NotSupportedException' could not be found (are you missing a using directive or an assembly reference?) 错误 CS0246:找不到类型或命名空间名称“StreamingContext”(是否缺少 using 指令或程序集引用?) - Error CS0246: The type or namespace name 'StreamingContext' could not be found (are you missing a using directive or an assembly reference?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM