Hello!
I am trying use Newtonsoft.Json and the JsonReader class taken from axgrind.azurewebsites.net/.../AX-2009-and-JSON-Parsing to process a json string. I copied the Newtonsoft.Json.dll into C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin\, and added a reference in AOT to this DLL. To be able to run my class on server side I also copied the DLL in C:\Program Files\Microsoft Dynamics AX\50\Server\ApplName\Bin\ on AOS server too. Now my class runs fine if its RunOn is set to Client, but fails with Server or Called from settings with the following error:
Request for the permission of type 'InteropPermission' failed.
(S)\Classes\InteropPermission\demand
(S)\Classes\CLRInterop\staticInvoke
(S)\Classes\JsonReader\loadJson - line 3
(S)\Classes\JsonReader\parseJson - line 6
(S)\Classes\XMI_JSonTest\run - line 21
(C)\Classes\XMI_JSonTest\main - line 7
The JSonReader class' RunOn is set to CalledFrom.
The code that fails:
void run()
{
JsonReader reader;
Newtonsoft.Json.Linq.JObject token;
str json, sKey, sName;
int i;
;
json = '{"key":86934,' +
'"name":"Data",' +
'"folders":[{"key":90296,"name":"Folder 1"},' +
'{"key":90294,"name":"Folder 2"},' +
'{"key":90295,"name":"Folder 3"},' +
'{"key":90292,"name":"Folder 4"},' +
'{"key":90293,"name":"Folder 5"},' +
'{"key":90297,"name":"Folder 6"}' +
']' +
'}';
new InteropPermission(InteropKind::ClrInterop);
reader = jsonreader::parseJson( json );
...
CodeAccessPermission::revertAssert();
}
The code stops executing at line
reader = jsonreader::parseJson( json );
public static JsonReader parseJson(str _json)
{
JsonReader reader = new JsonReader();
;
reader.loadJson(_json);
return reader;
}
public void loadJson(str _json)
{
jObject = Newtonsoft.Json.Linq.JObject::Parse(_json);
}
What am I doing wrong?
Thank you!