我目前正在尝试将 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/