字典不可被序列化,並且因此不能被髮送給我的客戶的JavaScript經由SignalR代碼作爲一個Javascript(僞)關聯數組...使用SignalR,我如何向Javascript發送字典(關聯數組)?
在.NET,我的複雜類型是:
public class MyClass {
public [primitive] whatever {get;set;}
...
public Dictionary<string, string> Properties { get; set; }
}
,並在Javascript中,我希望能夠引用這樣的數據:
data.Properties["key"]
更新:
我想送首先對字符串進行字符串化,因爲我通過SQL Service Broker路由實例。在這條線:
XmlSerializer serializer = new XmlSerializer(typeof(T));
其中T是typeof運算MyClass的
有反射型的誤差[MyClass的]
無法序列類型System.Collections.Generic的成員[MyClass的]的.properties .Dictionary`2 [[System.String,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089],[System.String,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]],因爲它實現了IDictionary。
我覺得我要回答我的問題...
我道歉@ halter73,我序列化到從一個字符串第一...(我通過SQL Service Broker彈跳對象實例)。我已經更新了這個問題。 – Novox 2014-09-26 12:18:06