当我有这个 c++ cli 代码时:
#pragma managed
ref class mcSessions: ConcurrentDictionary <String ^, mcSession^>
{ //<---- warning here
private:
static mcSessions ^g_Sessions;
TimeSpan MaxIdleTime;
mcSessions (TimeSpan newMaxIdleTime);
public:
static void Initialize (long MaxIdleMinutes);
static void Shutdown ();
static void CreateSession (String ^&SessionId);
static void RunInSession (String ^SessionId, String ^Command);
static void RemoveSession (String ^SessionId);
};
我在第一个 { 上收到警告 C4538。有没有人知道为什么会发生这种情况以及它警告什么,或者这也是一个编译器错误,因为它是针对这个问题中的情况:使用 C++/CLI 的看似不恰当的编译警告
尽管我看到它们有些相关,但我没有Group
对象而是ConcurrentDictionary
. 我正在使用针对 .NET 4.0 框架的 Visual Studio 2010 并使用 /clr 编译器标志进行编译。
确切的错误信息是:
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary::Node ^,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>::Node ^,
1> dimension=1
1> ]
1> d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25) : see reference to class generic instantiation 'System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>' being compiled
1> d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25) : see reference to class generic instantiation 'System::Collections::Concurrent::ConcurrentDictionary<TKey,TValue>' being compiled
1> with
1> [
1> TKey=System::String ^,
1> TValue=IamPowershell::mcSession ^
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary::Node ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1> This diagnostic occurred while importing type 'System::Collections::Concurrent::ConcurrentDictionary::Node ' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=System::Collections::Concurrent::ConcurrentDictionary<System::String ^,mcSession ^>::Node ^,
1> dimension=1
1> ]
1>d:\t4edevnet2010\umra2\iampowershell\mcIpSessions.h(25): warning C4538: 'cli::array<Type,dimension> ^' : const/volatile qualifiers on this type are not supported
1> with
1> [
1> Type=int,
1> dimension=1
1> ]
1>