edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;C1131894
File: IronRuby.Tests.csproj
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;C1131894  (server)    10/3/2009 11:34 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;Serialization
@@ -89,6 +89,7 @@
     <Compile Include="Runtime\RangeTests.cs" />
     <Compile Include="Runtime\RegexTests.cs" />
     <Compile Include="Runtime\RubyArrayTests.cs" />
+    <Compile Include="Runtime\RemotingTests.cs" />
     <Compile Include="Runtime\SplattingTests.cs" />
     <Compile Include="Runtime\StringTests.cs" />
     <Compile Include="Runtime\SuperTests.cs" />
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1158858
File: RubyTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1158858  (server)    10/3/2009 11:47 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;Serialization
@@ -656,6 +656,8 @@
                 Dlr_Methods,
                 Dlr_Visibility,
                 Dlr_Languages,
+
+                Serialization1,
             };
         }
     }
===================================================================
add: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RemotingTests.cs
File: RemotingTests.cs
===================================================================
--- [no source file]
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RemotingTests.cs;Serialization
@@ -1,0 +1,61 @@
+?/* ****************************************************************************
+ *
+ * Copyright (c) Microsoft Corporation. 
+ *
+ * This source code is subject to terms and conditions of the Microsoft Public License. A 
+ * copy of the license can be found in the License.html file at the root of this distribution. If 
+ * you cannot locate the  Microsoft Public License, please send an email to 
+ * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
+ * by the terms of the Microsoft Public License.
+ *
+ * You must not remove this notice, or any other, from this software.
+ *
+ *
+ * ***************************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using IronRuby.Builtins;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.IO;
+using Microsoft.Scripting.Utils;
+using Microsoft.Scripting.Hosting;
+using IronRuby.Runtime;
+
+namespace IronRuby.Tests {
+    public partial class Tests {
+        [Options(NoRuntime = true)]
+        public void Serialization1() {
+            var encodings = new object[] {
+                RubyEncoding.KCodeEUC,
+                RubyEncoding.KCodeSJIS,
+                RubyEncoding.UTF8,
+                RubyEncoding.GetRubyEncoding("SJIS"),
+            };
+
+            Assert(ArrayUtils.ValueEquals(encodings, Roundtrip(encodings)));
+
+            var s = MutableString.Create("foo", RubyEncoding.UTF8);
+            var rs = Roundtrip(s);
+            Assert(s.Equals(rs));
+
+            var e = new Exception("msg");
+            var ed = RubyExceptionData.GetInstance(e);
+            ed.Backtrace = new RubyArray(new[] { 1, 2, 3 });
+
+            var re = Roundtrip(e);
+            var rde = RubyExceptionData.TryGetInstance(re);
+            Assert(rde != null);
+            Assert(ArrayUtils.ValueEquals(rde.Backtrace.ToArray(), new object[] { 1,2,3 }));
+        }
+
+        private T Roundtrip<T>(T obj) {
+            var stream = new MemoryStream();
+            var f = new BinaryFormatter();
+            f.Serialize(stream, obj);
+            stream.Seek(0, SeekOrigin.Begin);
+            return (T)f.Deserialize(stream);
+        }
+    }
+}
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyArray.cs;C1040664
File: RubyArray.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyArray.cs;C1040664  (server)    10/3/2009 11:29 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyArray.cs;Serialization
@@ -22,6 +22,8 @@
 using Microsoft.Scripting.Utils;
 using IronRuby.Runtime.Calls;
 using IronRuby.Runtime.Conversions;
+using System.Security.Permissions;
+using System.Runtime.Serialization;
 
 namespace IronRuby.Builtins {
 
@@ -29,6 +31,7 @@
     /// Implements Ruby array.
     /// Not thread safe (even when frozen).
     /// </summary>
+    [Serializable]
     [DebuggerDisplay("{GetDebugView()}")]
     public partial class RubyArray : IList<object>, IList, IRubyObjectState, IDuplicable {
         private object[]/*!*/ _content;
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs;C1107696
File: RubyEncoding.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs;C1107696  (server)    10/3/2009 11:29 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs;Serialization
@@ -24,10 +24,11 @@
 using System.Text;
 using System.Diagnostics;
 using System.Threading;
-using Microsoft.Scripting;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
 using Microsoft.Scripting.Utils;
+using Microsoft.Scripting.Runtime;
 using IronRuby.Runtime;
-using Microsoft.Scripting.Runtime;
 using IronRuby.Compiler;
 
 namespace IronRuby.Builtins {
@@ -37,7 +38,8 @@
     /// Instances of this class are app-domain singletons. That's all right as far as the class is readonly and doesn't implement IRubyObject.
     /// Taint, frozen flags and instance variables need to be stored in per-runtime lookaside table.
     /// </summary>
-    public class RubyEncoding : IExpressionSerializable {
+    [Serializable]
+    public class RubyEncoding : ISerializable, IExpressionSerializable {
         #region Singletons
 
         internal const int CodePageBinary = 0;
@@ -124,6 +126,40 @@
             _maxBytesPerChar = strictEncoding.GetMaxByteCount(1);
         }
 
+        #region Serialization
+#if !SILVERLIGHT
+        private RubyEncoding(SerializationInfo/*!*/ info, StreamingContext context) {
+            throw Assert.Unreachable;
+        }
+
+        [Serializable]
+        internal sealed class Deserializer : ISerializable, IObjectReference {
+            private readonly int _codePage;
+            private readonly bool _isKCoding;
+
+            private Deserializer(SerializationInfo/*!*/ info, StreamingContext context) {
+                _codePage = info.GetInt32("CodePage");
+                _isKCoding = info.GetBoolean("IsKCoding");
+            }
+
+            public object GetRealObject(StreamingContext context) {
+                return _isKCoding ? TryGetKCoding(_codePage) : GetRubyEncoding(_codePage);
+            }
+
+            void ISerializable.GetObjectData(SerializationInfo/*!*/ info, StreamingContext context) {
+                throw Assert.Unreachable;
+            }
+        }
+
+        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
+        void ISerializable.GetObjectData(SerializationInfo/*!*/ info, StreamingContext context) {
+            info.AddValue("CodePage", _encoding.CodePage);
+            info.AddValue("IsKCoding", IsKCoding);
+            info.SetType(typeof(Deserializer));
+        }
+#endif
+        #endregion
+
         public int MaxBytesPerChar {
             get { return _maxBytesPerChar; }
         }
@@ -382,7 +418,7 @@
         }
 
         Expression/*!*/ IExpressionSerializable.CreateExpression() {
-            // TODO: use a static fields, deal with KCODEs
+            // TODO: use static fields, deal with KCODEs
             return Methods.CreateEncoding.OpCall(Expression.Constant(_encoding.CodePage));
         }
 #else
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs;C1068248
File: RubyExceptionData.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs;C1068248  (server)    10/3/2009 11:29 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs;Serialization
@@ -36,7 +36,7 @@
     public sealed class RubyExceptionData {
         internal static readonly Microsoft.Scripting.Utils.ThreadLocal<InterpretedFrame> CurrentInterpretedFrame = new Microsoft.Scripting.Utils.ThreadLocal<InterpretedFrame>();
 
-        private static readonly object/*!*/ _DataKey = new object();
+        private static readonly object/*!*/ _DataKey = typeof(RubyExceptionData);
         internal const string TopLevelMethodName = "#";
 
 #if SILVERLIGHT
@@ -60,6 +60,7 @@
         private Exception/*!*/ _visibleException;
 #if DEBUG
         // For asynchronous exceptions, this is useful to figure out which thread raised the exception
+        [NonSerialized]
         private Thread/*!*/ _throwingThread;
 #endif
 
@@ -69,7 +70,8 @@
         // can be set explicitly by the user (even to nil):
         private RubyArray _backtrace;
 
-        private CallSite<Func<CallSite, RubyContext, Exception, RubyArray, object>>/*!*/ _setBacktraceCallSite;
+        [NonSerialized]
+        private CallSite<Func<CallSite, RubyContext, Exception, RubyArray, object>> _setBacktraceCallSite;
 
         private RubyExceptionData(Exception/*!*/ exception) {
             _exception = exception;
===================================================================
