我得到一个:

找不到类型或名称空间名称

错误的c# WPF应用程序在VS2010。这部分代码编译得很好,但突然就出现了这个错误。我已经尝试删除项目引用和using语句,关闭VS2010并重新启动,但我仍然有这个问题。

有什么想法,为什么这可能会发生,似乎我在做正确的事情re Reference & using语句?

我还注意到在VS2010,智能感知的名称空间是工作的好,所以它似乎VS2010有项目引用,是看到名称空间在一方面,但在编译期间没有看到它?


当前回答

我的情况和这里讨论的一样,但在我移除系统之前没有解决它。来自引用列表的核心引用(没有它一切都可以正常工作)

希望这能帮助到一些人,因为这个问题很令人沮丧

其他回答

在我的例子中,我发现VisualStudio中的引用有一个三角形和一个感叹号,就像这个图像,

然后,我右键单击删除它,并正确地添加dll引用,问题就解决了。

我在试图以代理的身份在本地机器上运行Visual Studio Team Services构建时遇到此错误。

它在我的常规工作空间中工作得很好,我能够在本地代理文件夹中打开SLN文件,一切都编译好了。

有问题的DLL存储在项目中Lib/MyDLL.DLL,并在csproj文件中引用此DLL:

<Reference Include="MYDLL, Version=2009.0.0.0, Culture=neutral, PublicKeyToken=b734e31dca085caa">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>Lib\MYDLL.dll</HintPath>
</Reference>

结果是,尽管有提示路径,它还是找不到文件。我认为msbuild可能是相对于SLN文件而不是项目文件。

在任何情况下,如果您得到的消息是无法解析此引用。无法定位程序集,请确保DLL位于msbuild可访问的位置。

我有点作弊,发现一条消息说“参考\bin\xxx.dll”,然后把dll复制到那里。

在我的情况下,我卸载项目,然后:

Opened myProject.csproj and update the ToolsVersion="4.0" to ToolsVersion="12.0"(I'm using vs 2017)(using Paulus's answer https://stackoverflow.com/a/64552201/1594487). Deleted following lines from the myProject.csproj: <Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

问题解决了。

我知道这是踢死马,但我有这个错误和框架在哪里好。我的问题基本上是声明无法找到接口,但它构建和访问都很好。所以我开始思考:“为什么只有这个界面,而其他人都工作得很好?”

最终,我使用WCF的端点接口访问了一个服务,该端点接口使用的是实体版本6,而其余的项目使用的是版本5。我没有使用NuGet,而是简单地将NuGet包复制到本地存储库以供重用,并以不同的方式列出它们。

例如,EntityFramework6.dll vs . EntityFramework.dll。

然后,我将引用添加到客户端项目,噗的一声,我的错误消失了。我意识到这是一个边缘情况,因为大多数人不会混合实体框架的版本。

I had a similar issue: The compiler was unable to detect a folder inside the same project, so a using directive linking to that folder generated an error. In my case, the problem originated from renaming the folder. Even though I updated the namespace of all the classes inside that folder, the project info somehow failed to update. I tried everything: deleting the .suo file and the bin and obj folders, cleaning the solution, reloading the project - nothing helped. I resolved the problem by deleting the folder and the classes inside, creating a new folder and creating new classes in that new folder (simply moving the classes inside the new folder didn't help).

PS:以我为例,我正在开发一个web应用程序,但这个问题可能发生在不同类型的项目中。