private void Marshal(PortableWriterImpl writer)
        {
            var pos = writer.Stream.Position;

            try
            {
                if (Error == null)
                {
                    writer.WriteByte((byte)Entry.State);

                    if (Entry.State == MutableCacheEntryState.ValueSet)
                    {
                        writer.Write(Entry.Value);
                    }

                    writer.Write(ProcessResult);
                }
                else
                {
                    writer.WriteByte((byte)MutableCacheEntryState.ErrPortable);
                    writer.Write(new PortableResultWrapper(Error));
                }
            }
            catch (Exception marshErr)
            {
                writer.Stream.Seek(pos, SeekOrigin.Begin);

                writer.WriteByte((byte)MutableCacheEntryState.ErrString);

                if (Error == null)
                {
                    writer.WriteString(string.Format(
                                           "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
                                           "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
                else
                {
                    writer.WriteString(string.Format(
                                           "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
                                           "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
            }
        }
        private void Marshal(PortableWriterImpl writer)
        {
            var pos = writer.Stream.Position;

            try
            {
                if (Error == null)
                {
                    writer.WriteByte((byte) Entry.State);

                    if (Entry.State == MutableCacheEntryState.ValueSet)
                        writer.Write(Entry.Value);

                    writer.Write(ProcessResult);
                }
                else
                {
                    writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
                    writer.Write(new PortableResultWrapper(Error));
                }
            }
            catch (Exception marshErr)
            {
                writer.Stream.Seek(pos, SeekOrigin.Begin);

                writer.WriteByte((byte) MutableCacheEntryState.ErrString);

                if (Error == null)
                {
                    writer.WriteString(string.Format(
                    "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
                else
                {
                    writer.WriteString(string.Format(
                    "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
            }
        }