System.Security.Permissions.SecurityPermission,mscorlib,Version = 4.0.0。,Culture = nuetral failed 2011 2011

时间:2014-04-07 03:21:29

标签: json dynamics-crm-2011

我正在尝试在CRM 2011中反序列化json字符串.JSON字符串是任意的,并不总是返回相同的字段(键)。我正在尝试使用system.runtime.serialization.json datacontractjsonserialzer方法。我在另一篇文章中找到了以下代码,我已根据需要进行了修改:

namespace test
{
[Serializable]
public class stringObjectDictionary : ISafeSerializationData
{
public static Dictonary<string, object> dict;

public stringObjectDictionary()
{ dict = new Dictionary<string, object>(); }

protected stringObjectDictionary(SerializationInfo info, StreamingContext context)
{
dict = new Dictionary<string, object>();
foreach (Serialization entry in info)
{ dict.Add(key, dict[key]); }
}

void ISafeSerializationData.CompleteDeserialization(object obj)
{
Dictionary<string, object> _dict = obj as Dictionary<string, object>;
foreach (string key in dict.Keys)
{ _dict.Add(key, dict[key] }
}

我在这里打电话给上面的人:

test.stringObjectDictionary[] dummyArray = { new test.stringObjectDictionary() };
DataContractJsonSerializer js = new DataContractJsonSerializer(dummyArray.GetType());
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(JSONString));
test.stringObjectDictionary[] dictArray =       (test.stringObjectDictionary[]).js.ReadObject(stream);

我正在使用以下测试JSON:

 string testJSON = @"[{""ID"":34,""crmID"":""df4a2ab8-f1ad-e311-abb3-00155d02ea01""}, {""ID"":35,""crmID"":""df4a2ab8-f1ad-e311-abb3-0015d042fg94""}];

当我构建和部署并测试工作流时,我收到了安全错误。这部署在沙箱环境中,需要在CRM中在线工作。是否可以允许类stringObjectDictionary成为完全受信任的代码,以便它可以访问system.security名称空间?

0 个答案:

没有答案