[Ironruby-core] Problem with Marshal.load in Silverlight

Charles Strahan charles.c.strahan at gmail.com
Sun Jul 25 05:25:04 EDT 2010

I've run into a problem when using Marshal.load in Silverlight - the
following exception is thrown:

NotSupportedException: Class IronRuby.Builtins.RubyObject does not have a
valid deserializing constructor

I tracked the code down to RubyUtils.CreateObject(RubyClass/*!*/ theclass,
IEnumerable<KeyValuePair<string, object>>/*!*/ attributes).  I see that
CreateObject will always throw in Silverlight when the type is assignable
from ISerializable:

        public static object/*!*/ CreateObject(RubyClass/*!*/ theclass,
IEnumerable<KeyValuePair<string, object>>/*!*/ attributes) {
            Assert.NotNull(theclass, attributes);

            Type baseType = theclass.GetUnderlyingSystemType();
            object obj;
            if (typeof(ISerializable).IsAssignableFrom(baseType)) {
#if !SILVERLIGHT // serialization
                BindingFlags bindingFlags = BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Instance;
                ConstructorInfo ci = baseType.GetConstructor(bindingFlags,
null, _serializableTypeSignature, null);
                if (ci == null) {
                string message = String.Format("Class {0} does not have a
valid deserializing constructor", baseType.FullName);
                    throw new NotSupportedException(message);
#if !SILVERLIGHT // serialization
                SerializationInfo info = new SerializationInfo(baseType, new
                info.AddValue(SerializationInfoClassKey, theclass);
                foreach (var pair in attributes) {
                    info.AddValue(pair.Key, pair.Value);
                obj = ci.Invoke(new object[2] { info, new
StreamingContext(StreamingContextStates.Other, theclass) });
            } else {
                obj = CreateObject(theclass);
                foreach (var pair in attributes) {
                    theclass.Context.SetInstanceVariable(obj, pair.Key,
            return obj;

Is this a bug, perhaps? I'd love to step through the code and find for
myself, but I can't seem to build IronRuby using the Silverlight3 and
Silverlight4 build configurations (I get a ton of errors - any help getting
it to build would rock!).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100725/31018f0f/attachment.html>

More information about the Ironruby-core mailing list