+
+ /*
+ * We deserialize the exception in another try-catch so we can catch
+ * serialization failure exceptions.
+ */
+ serialization_clause = &clauses [1];
+ serialization_clause->try_offset = mono_mb_get_label (mb);
+
+ mono_mb_emit_managed_call (mb, method_rs_serialize_exc, NULL);
+ mono_mb_emit_stloc (mb, loc_serialized_exc);
+ mono_mb_emit_ldarg (mb, 2);
+ mono_mb_emit_ldloc (mb, loc_serialized_exc);
+ mono_mb_emit_byte (mb, CEE_STIND_REF);
+ pos_leave_serialization = mono_mb_emit_branch (mb, CEE_LEAVE);
+
+ /* Serialization exception catch */
+ serialization_clause->flags = MONO_EXCEPTION_CLAUSE_NONE;
+ serialization_clause->try_len = mono_mb_get_pos (mb) - serialization_clause->try_offset;
+ serialization_clause->data.catch_class = mono_defaults.object_class;
+
+ /* handler code */
+ serialization_clause->handler_offset = mono_mb_get_label (mb);
+
+ /*
+ * If the serialization of the original exception failed we serialize the newly
+ * thrown exception, which should always succeed, passing it over to the calling
+ * domain.
+ */