Visual Studio 2010不会看到命名空间,但它存在

时间:2014-01-26 11:05:54

标签: c# visual-studio-2010 visual-studio reference namespaces

我有解决方案,有5个项目。其中之一:“Project.Core.Common”(。NEt Framework 3.5)。我有一个问题。当我尝试编译时,我得到错误:

  

错误79类型或命名空间名称'Server'不存在于   namespace'DllFile.Logging'(你错过了一个程序集吗?   参考?)D:\ Solution \ Project.Core.Common

但是这个名称空间DllFile.Logging.Server存在。我可以通过在对象浏览器中打开DllFile.dll来看到它。

参考我项目中添加的DllFile.dll

DllFile.dll具有.NET FW 2.0.50727运行时版本。

我收到74条关于此DllFile.dll的警告:

  

警告4主要参考“DllFile.Logging.Server,Version = 6.3.1.0,   Culture = neutral,processorArchitecture = MSIL“无法解决   因为它与.NET Framework程序集间接依赖   “mscorlib,版本= 4.0.0.0,文化=中性,   PublicKeyToken = b77a5c561934e089“其中包含更高版本”4.0.0.0“   比当前目标中的版本“2.0.0.0”   框架。 Project.Core.Common

DllFile.dll不使用任何依赖关系到第4个框架。它用2.0框架编写。

重要的是:除了我的以外,这个项目在任何计算机上都没有任何错误编译。我检查了在以下环境中编译它:

VS 2010 (Windows XP SP3 x86)
VS 2010 (Windows 7 x86)
VS 2010 (Windows 7 x64)
VS 2013 (Windows 8.1 x64)

在每台计算机上,这个项目编译得很好。但是在我的电脑上(VS 2010 Windows XP SP3 x86)我收到此错误和警告。

我尝试做的事情:

  • 我完全卸载了VS 2010及其所有组件,然后重新安装。
  • 我删除了以下文件夹:
  

C:\ Documents and Settings \ User \ Local Settings \ Application   数据\装配

     

C:\ Documents and Settings \ User \ Local Settings \ Application Data \ cache   (删除以防万一)

     

C:\ Documents and Settings \ User \ Local Settings \ Application   Data \ Microsoft \ Team Foundation

     

C:\ Documents and Settings \ User \ Local Settings \ Application   数据\微软\ VisualStudio的

     

C:\ Documents and Settings \ User \ Local Settings \ Application   数据\微软\ VSCommon

     

C:\ Documents and Settings \ User \ Local Settings \ Application   数据\ WebsiteCache \

     

C:\ Documents and Settings \ User \ VSWebCache

     

C:\ Documents and Settings \ All Users \ Application   数据\微软\ VSTAHost \ SSIS_ScriptTask \ 9.0 \ ItemTemplatesCache

     

C:\ Documents and Settings \ All Users \ Application Data \ Microsoft \ VSTAHost \ SSIS_ScriptTask \ 9.0 \ ProjectTemplatesCache

     

C:\ Documents and Settings \ All Users \ Application Data \ VS \ vs10sp1 \ SetupCache

  • 删除了以下文件:
C:\Documents and Settings\All Users\Application Data\Microsoft\VisualStudio\10.0\vs000223.dat
C:\Documents and Settings\All Users\Application Data\Microsoft\VisualStudio\10.0\1033\devenv.CTM
C:\Documents and Settings\All Users\Application Data\Microsoft\VisualStudio\10.0\1033\ResourceCache.dll
C:\Documents and Settings\All Users\Application Data\Microsoft\VSA\9.0\1033\ResourceCache.dll
C:\Documents and Settings\All Users\Application Data\Microsoft\VSA\9.0\1033\vsaenv10.CTM
C:\Documents and Settings\All Users\Application Data\Microsoft\VSTAHost\SSIS_ScriptComponent\9.0\1033\ResourceCache.dll
C:\Documents and Settings\All Users\Application Data\Microsoft\VSTAHost\SSIS_ScriptTask\9.0\1033\ResourceCache.dll
  • 清除以下文件夹:
C:\Documents and Settings\User\Local Settings\Temp
  • 我也尝试清除VS缓存。我在cmd中执行了以下命令:
cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
devenv /resetuserdata

但没有任何帮助。

我还能做些什么来解决我的奇怪问题? (重新安装Windows除外)

编辑:

  1. 更改参数'DllFile.dll'的'复制本地'(true / false)属性没有帮助。

  2. 我尝试创建新的空项目并添加对此库'DllFile.dll'的引用,此错误也存在于空项目中。所以问题不在于我的实际项目。

2 个答案:

答案 0 :(得分:1)

转到解决方案资源管理器,然后选择“显示所有文件”。然后来到您的项目bin并展开DllFile.dll并看到有DllFile.dll.refresh文件,如果是,则删除并清理解决方案并重建您的项目应该成功构建。

答案 1 :(得分:0)

这是一个旧错误,即使在 Visual Studio 2019(社区版)中也存在。 IDE 不会更新您要从中引用另一个项目的项目文件。但是在设置中,您会看到链接就在那里。您应该手动添加引用:

将此写入项目文件(或可以从链接正常工作的另一个项目复制):

  <ItemGroup>
    <ProjectReference Include="...path...\YourProject.csproj" />
  </ItemGroup>

这解决了问题。