/// <summary>
        /// Gets the exception from the RemoteExceptionInformation
        /// </summary>
        /// <param name="remoteExceptionInformation">RemoteExceptionInformation</param>
        /// <param name="result">Exception from the remote side</param>
        /// <returns>true if there was a valid exception, false otherwise</returns>
        public static bool ToException(RemoteExceptionInformation remoteExceptionInformation, out Exception result)
        {
            Requires.ThrowIfNull(remoteExceptionInformation, "RemoteExceptionInformation");

            // try to de-serialize the bytes in to the exception
            Exception res;

            if (TryDeserializeException(remoteExceptionInformation.Data, out res))
            {
                result = res;
                return(true);
            }


            // try to de-serialize the bytes in to exception message and create service exception
            if (TryDeserializeServiceException(remoteExceptionInformation.Data, out result))
            {
                return(true);
            }

            //Set Reason for Serialization failure. This can happen in case where serialization succeded
            //but deserialization fails as type is not accessible
            result = res;
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Gets the exception from the RemoteExceptionInformation
        /// </summary>
        /// <param name="remoteExceptionInformation">RemoteExceptionInformation</param>
        /// <param name="result">Exception from the remote side</param>
        /// <returns>true if there was a valid exception, false otherwise</returns>
        public static bool ToException(RemoteExceptionInformation remoteExceptionInformation, out Exception result)
        {
            // try to de-serialize the bytes in to the exception
            if (TryDeserializeException(remoteExceptionInformation.Data, out result))
            {
                return(true);
            }

            // try to de-serialize the bytes in to exception message and create service exception
            if (TryDeserializeServiceException(remoteExceptionInformation.Data, out result))
            {
                return(true);
            }

            result = null;
            return(false);
        }