You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
I get an uncaught exception of type System.InvalidCastException when I try to execute the following:
// Load the document
using (Stream strm = archive.GetFileStream("package.json"))
{
using (StreamReader reader = new StreamReader(strm))
{
// The following line crashes!
dynamic rootObject = JsonConvert.DeserializeObject(reader.ReadToEnd());
}
}
The generated JSIL line that causes the crash somewhere in the NewtonSoft.Json.dll js code looks like this:
var rootObject = $T0D().DeserializeObject(($S05().Construct(strm)).ReadToEnd());
Exception message in log div:
Unhandled exception at http://127.0.0.1/web/Libraries/JSIL.Core.js line 5034:
Uncaught System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.JsonTextReader' to type 'Newtonsoft.Json.Serialization.TraceJsonReader'.
Edit: The C# code runs just fine in a compiled Windows application, so the JSON data isn't corrupted. Edit 2: I also checked in the javascript debugger that the stream contains the correct json text value, so everything got loaded correctly from the local file storage.
The text was updated successfully, but these errors were encountered:
I have the same problem (using Newtonsoft.JSON 7.0.1, because modern ones do not even compile for JSIL).
I am trying to call a C# method from JS like this
// Then in the browser console I try to instantiate MyClass
asm.mynamespace.MyClass(JSON.stringify({a:1, b: "hello"}))
This creates the same error message as shown by Kyoril: Unable to cast object of type 'Newtonsoft.Json.JsonTextReader' to type 'Newtonsoft.Json.Serialization.TraceJsonReader'.
Stacktrace:
'Error\n
at captureStackTrace (http://127.0.0.1:5500/Libraries/IgnoredBCL/JSIL.Bootstrap.js:1961:15)\n
at System_InvalidCastException._ctor [as _ctor$304=void] (http://127.0.0.1:5500/Libraries/IgnoredBCL/JSIL.Bootstrap.js:1978:28)\n
at System_InvalidCastException.System_Exception__ctor [as _ctor] (jsil://closure/System.Exception..ctor:12:25)\n
at System_InvalidCastException._ctor$304=void (http://127.0.0.1:5500/Libraries/IgnoredBCL/JSIL.Bootstrap.js:2063:44)\n
at System_InvalidCastException__ctor [as _ctor] (jsil://closure/System.InvalidCastException..ctor:12:25)\n
at new System_InvalidCastException (jsil://closure/System.InvalidCastException:20:21)\n
at throwCastError (http://127.0.0.1:5500/Libraries/JSIL.Core.js:5034:11)\n
at Function.Cast [as $Cast] (http://127.0.0.1:5500/Libraries/JSIL.Core.js:5139:7)\n
at Newtonsoft_Json_JsonSerializer.JsonSerializer_DeserializeInternal (http://127.0.0.1:5500/root/Newtonsoft.Json,%20Version=7.0.0.0,%20Culture=neutral,%20PublicKeyToken=30ad4fe6b2a6aeed.js:18658:97)\n
at Newtonsoft_Json_JsonSerializer.JsonSerializer_Deserialize$06 [as Deserialize$769,301=300] (http://127.0.0.1:5500/root/Newtonsoft.Json,%20Version=7.0.0.0,%20Culture=neutral,%20PublicKeyToken=30ad4fe6b2a6aeed.js:18631:17)'
I get an uncaught exception of type System.InvalidCastException when I try to execute the following:
The generated JSIL line that causes the crash somewhere in the NewtonSoft.Json.dll js code looks like this:
var rootObject = $T0D().DeserializeObject(($S05().Construct(strm)).ReadToEnd());
Exception message in log div:
Edit: The C# code runs just fine in a compiled Windows application, so the JSON data isn't corrupted.
Edit 2: I also checked in the javascript debugger that the stream contains the correct json text value, so everything got loaded correctly from the local file storage.
The text was updated successfully, but these errors were encountered: