Ben Hall
2010-Jun-02 22:01 UTC
[Ironruby-core] Bug in mscorlib, IronRuby, NewtonSoft.json..... or my code?
Hi, I''m trying to use a third party library which has a dependency on NewtonSoft.json. I create a class within IronRuby and attempt to serialise the object to Json however it throws a null reference exception from within mscorlib. Any ideas?? Example is below: Thanks Ben class Company attr_accessor :Name, :Id end c = Company.new c.Name = ''test'' require ''Newtonsoft.Json'' include Newtonsoft::Json JsonConvert.serialize_object c mscorlib:0:in `Equals'': Object reference not set to an instance of an object. (System::NullReferenceException) from mscorlib:0:in `IndexOf'' from mscorlib:0:in `IndexOf'' from mscorlib:0:in `IndexOf'' from Newtonsoft.Json:0:in `CheckForCircularReference'' from Newtonsoft.Json:0:in `SerializeList'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `SerializeISerializable'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `SerializeISerializable'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' from Newtonsoft.Json:0:in `SerializeObject'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' from Newtonsoft.Json:0:in `SerializeObject'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `SerializeISerializable'' from Newtonsoft.Json:0:in `SerializeValue'' from Newtonsoft.Json:0:in `Serialize'' from Newtonsoft.Json:0:in `SerializeInternal'' from Newtonsoft.Json:0:in `SerializeObject'' from Newtonsoft.Json:0:in `SerializeObject'' from (ir):1
Ivan Porto Carrero
2010-Jun-03 04:55 UTC
[Ironruby-core] Bug in mscorlib, IronRuby, NewtonSoft.json..... or my code?
make the class backed by a real .NET Type not a ruby type and the serializer will work again --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero On Thu, Jun 3, 2010 at 12:01 AM, Ben Hall <ben2004uk at googlemail.com> wrote:> Hi, > > I''m trying to use a third party library which has a dependency on > NewtonSoft.json. I create a class within IronRuby and attempt to > serialise the object to Json however it throws a null reference > exception from within mscorlib. > > Any ideas?? Example is below: > > Thanks > > Ben > > class Company > attr_accessor :Name, :Id > end > > c = Company.new > c.Name = ''test'' > > > require ''Newtonsoft.Json'' > include Newtonsoft::Json > JsonConvert.serialize_object c > > > mscorlib:0:in `Equals'': Object reference not set to an instance of an > object. (System::NullReferenceException) > from mscorlib:0:in `IndexOf'' > from mscorlib:0:in `IndexOf'' > from mscorlib:0:in `IndexOf'' > from Newtonsoft.Json:0:in `CheckForCircularReference'' > from Newtonsoft.Json:0:in `SerializeList'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `Serialize'' > from Newtonsoft.Json:0:in `SerializeInternal'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeObject'' > from (ir):1 > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100603/35b8e27e/attachment.html>
Mark Rendle
2010-Jun-03 08:51 UTC
[Ironruby-core] Bug in mscorlib, IronRuby, NewtonSoft.json..... or my code?
I''m halfway through a library which serializes dynamic types to JSON. I guess that should work in this case; I''ll post when it''s done. Cheers, Mark On Wed, Jun 2, 2010 at 11:01 PM, Ben Hall <ben2004uk at googlemail.com> wrote:> Hi, > > I''m trying to use a third party library which has a dependency on > NewtonSoft.json. I create a class within IronRuby and attempt to > serialise the object to Json however it throws a null reference > exception from within mscorlib. > > Any ideas?? Example is below: > > Thanks > > Ben > > class Company > attr_accessor :Name, :Id > end > > c = Company.new > c.Name = ''test'' > > > require ''Newtonsoft.Json'' > include Newtonsoft::Json > JsonConvert.serialize_object c > > > mscorlib:0:in `Equals'': Object reference not set to an instance of an > object. (System::NullReferenceException) > from mscorlib:0:in `IndexOf'' > from mscorlib:0:in `IndexOf'' > from mscorlib:0:in `IndexOf'' > from Newtonsoft.Json:0:in `CheckForCircularReference'' > from Newtonsoft.Json:0:in `SerializeList'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `WriteMemberInfoProperty'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `SerializeISerializable'' > from Newtonsoft.Json:0:in `SerializeValue'' > from Newtonsoft.Json:0:in `Serialize'' > from Newtonsoft.Json:0:in `SerializeInternal'' > from Newtonsoft.Json:0:in `SerializeObject'' > from Newtonsoft.Json:0:in `SerializeObject'' > from (ir):1 > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100603/22fdbbaf/attachment.html>