【发布时间】:2012-11-26 18:56:07
【问题描述】:
我最近安装了 VS2012。在 VS2010 下编译良好的 C++ 项目(使用 .Net 4.0)在 VS2012 上无法识别 HashSet<T>。我什至尝试过明确以下声明:
System::Collections::Generic::HashSet< String^ >^ _reasons;
但这只会导致错误:
error C2039: 'HashSet' : is not a member of 'System::Collections::Generic
文档说它在 System.Collections.Generic 中。 C++ 编译器不这么认为。
关于它的去向有什么想法吗?
【问题讨论】:
-
一个 C++ 项目(使用 .Net 4.0) 哎呀。在普通 C++中,有
unordered_set。 -
您是否引用了程序集
System.Core? System::Collections::Generic 命名空间存在于多个程序集中,如果您引用其中一个,而不是包含 HashSet 的那个,则会收到该错误消息。 -
明确添加 System.Core 作为参考。那解决了它。谢谢大卫!
标签: c++-cli visual-studio-2012 hashset