visual-studio-2012 - 找不到类型或命名空间

标签 visual-studio-2012 c#-2.0 msbuild-4.0

我目前正在尝试将 Visual Studio 2008 中的 WiX 3.5 自定义操作项目转换为 WiX 3.7 和 Visual Studio 2012,但出现以下异常:

The type or namespace name 'MyNamespace' could not be found (are you missing a using directive or an assembly reference?)



dll 肯定被引用,Visual Studio 2012 看到命名空间没有问题。命名空间下的所有内容甚至会在 Intellisense 中弹出,但是当我构建它时,我遇到了这个异常。

有人知道这里发生了什么吗?

附加信息:

我引用的命名空间是一个 .Net 2.0 库,而自定义操作项目是一个 .Net 2.0 项目。

编辑:

经过进一步调查,我收到了这个警告,我猜这是问题的根源:

The primary reference "MyNamespace, Version=8.5.1.20, Culture=neutral, PublicKeyToken=f593502af6ee46ae, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.



当这是一个 2.0 项目时,为什么要尝试使用 mscorelib 4.0?

最佳答案

所以事实证明,被引用的 dll 在编译为面向 .Net 2.0 框架时,是用 4.0 编译器编译的。切换项目用3.5编译器编译解决了这个问题。

关于visual-studio-2012 - 找不到类型或命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17859942/

相关文章:

msbuild - 如何重命名网络部署?

visual-studio-2010 - 创建单独的ClickOnce安装,可以通过使用MSBUILD更改程序集名称来一起安装

c++ - boost 1.53 python fatal error LNK1104 boost_python-vc110-mt-gd-1_53.lib

c++ - 如何确保 std::thread 是在多核中创建的?

c# - Visual Studio 2012 不显示文件夹已创建

visual-studio - 如何使用 Visual Studio 2012 和 NUnit 命令行工具生成代码覆盖率报告?

c# - C# 2.0 中的随机分钟数

c# - 视觉 C# Express 2010 : how to set language to C# 2. 0

c# - 如何在 C# 2.0 中使用匿名泛型委托(delegate)

visual-studio-2010 - SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x8013141A)