我得到一个:
找不到类型或名称空间名称
错误的c# WPF应用程序在VS2010。这部分代码编译得很好,但突然就出现了这个错误。我已经尝试删除项目引用和using语句,关闭VS2010并重新启动,但我仍然有这个问题。
有什么想法,为什么这可能会发生,似乎我在做正确的事情re Reference & using语句?
我还注意到在VS2010,智能感知的名称空间是工作的好,所以它似乎VS2010有项目引用,是看到名称空间在一方面,但在编译期间没有看到它?
我得到一个:
找不到类型或名称空间名称
错误的c# WPF应用程序在VS2010。这部分代码编译得很好,但突然就出现了这个错误。我已经尝试删除项目引用和using语句,关闭VS2010并重新启动,但我仍然有这个问题。
有什么想法,为什么这可能会发生,似乎我在做正确的事情re Reference & using语句?
我还注意到在VS2010,智能感知的名称空间是工作的好,所以它似乎VS2010有项目引用,是看到名称空间在一方面,但在编译期间没有看到它?
当前回答
我在项目资源管理器中打开项目下面的引用,将鼠标悬停在其中一个缺失的引用上,很快,它就找到了所有东西。然后我就可以成功地建造了。
运行Visual Studio Community 2019,版本16.8.4
其他回答
把我的解决方案加入到混合中,因为它有点不同,我花了一段时间来弄清楚。
In my case I added a new class to one project but because my version control bindings weren't set I needed to make the file writable outside of Visual Studio (via the VC). I had cancelled out of the save in Visual Studio but after I made the file writable outside VS I then hit Save All again in VS. This inadvertently caused the new class file to not be saved in the project..however..Intellisense still showed it up as blue and valid in the referencing projects even though when I'd try to recompile the file wasn't found and got the type not found error. Closing and opening Visual Studio still showed the issue (but if I had taken note the class file was missing upon reopening).
当我意识到这一点时,解决方法很简单:将项目文件设置为可写,将丢失的文件读入项目。现在都建好了。
我知道这个线程是旧的,但无论如何我共享,我必须安装导入程序集的所有第三方依赖项-因为导入的程序集不包括在Nuget包中,因此它的依赖项丢失了。
跳这个帮助:)
在我的情况下,我卸载项目,然后:
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')" />
问题解决了。
这个方法对我很管用。在定义了类名的类中,例如:公共类ABC,删除一个字符并等待一会儿。您的错误列表将增加,因为您更改了名称。现在把输入的字符放回去。这对我有用,希望对你也有用。祝你好运! !
我在试图以代理的身份在本地机器上运行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复制到那里。