Exemple #1
0
        private void ThrowQuotaReachedException()
        {
            string    message = string.Format(SRServiceModel.CacheQuotaReached, _maxCacheItems);
            Exception inner   = new QuotaExceededException(message);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
        }
        internal static Exception CreateMaxSentMessageSizeExceededException(long maxMessageSize)
        {
            string    message = SR.Format(SR.MaxSentMessageSizeExceeded, maxMessageSize);
            Exception inner   = new QuotaExceededException(message);

            return(new CommunicationException(message, inner));
        }
Exemple #3
0
 public static Exception GetFaultException(string faultString, string via, string contentType)
 {
     if (faultString == FramingEncodingString.EndpointNotFoundFault)
     {
         return(new EndpointNotFoundException(SR.Format(SR.EndpointNotFound, via)));
     }
     else if (faultString == FramingEncodingString.ContentTypeInvalidFault)
     {
         return(new ProtocolException(SR.Format(SR.FramingContentTypeMismatch, contentType, via)));
     }
     else if (faultString == FramingEncodingString.ServiceActivationFailedFault)
     {
         // TODO: Bring in exception or leave as is
         //return new ServiceActivationException(SR.Format(SR.Hosting_ServiceActivationFailed, via));
         return(new CommunicationException(SR.Format(SR.Hosting_ServiceActivationFailed, via)));
     }
     else if (faultString == FramingEncodingString.ConnectionDispatchFailedFault)
     {
         return(new CommunicationException(SR.Format(SR.Sharing_ConnectionDispatchFailed, via)));
     }
     else if (faultString == FramingEncodingString.EndpointUnavailableFault)
     {
         return(new EndpointNotFoundException(SR.Format(SR.Sharing_EndpointUnavailable, via)));
     }
     else if (faultString == FramingEncodingString.MaxMessageSizeExceededFault)
     {
         Exception inner = new QuotaExceededException(SR.FramingMaxMessageSizeExceeded);
         return(new CommunicationException(inner.Message, inner));
     }
     else if (faultString == FramingEncodingString.UnsupportedModeFault)
     {
         return(new ProtocolException(SR.Format(SR.FramingModeNotSupportedFault, via)));
     }
     else if (faultString == FramingEncodingString.UnsupportedVersionFault)
     {
         return(new ProtocolException(SR.Format(SR.FramingVersionNotSupportedFault, via)));
     }
     else if (faultString == FramingEncodingString.ContentTypeTooLongFault)
     {
         Exception inner = new QuotaExceededException(SR.Format(SR.FramingContentTypeTooLongFault, contentType));
         return(new CommunicationException(inner.Message, inner));
     }
     else if (faultString == FramingEncodingString.ViaTooLongFault)
     {
         Exception inner = new QuotaExceededException(SR.Format(SR.FramingViaTooLongFault, via));
         return(new CommunicationException(inner.Message, inner));
     }
     else if (faultString == FramingEncodingString.ServerTooBusyFault)
     {
         return(new ServerTooBusyException(SR.Format(SR.ServerTooBusy, via)));
     }
     else if (faultString == FramingEncodingString.UpgradeInvalidFault)
     {
         return(new ProtocolException(SR.Format(SR.FramingUpgradeInvalid, via)));
     }
     else
     {
         return(new ProtocolException(SR.Format(SR.FramingFaultUnrecognized, faultString)));
     }
 }
Exemple #4
0
        void ThrowQuotaReachedException()
        {
            string    message = SR.GetString(SR.CacheQuotaReached, this.maxCacheItems);
            Exception inner   = new QuotaExceededException(message);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
        }
Exemple #5
0
        private void ThrowQuotaReachedException()
        {
            string    message        = System.ServiceModel.SR.GetString("CacheQuotaReached", new object[] { this.maxCacheItems });
            Exception innerException = new QuotaExceededException(message);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, innerException));
        }
Exemple #6
0
        private void ThrowQuotaReachedException()
        {
            string    message = SR.Format(SR.CacheQuotaReached, Capacity);
            Exception inner   = new QuotaExceededException(message);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
        }
Exemple #7
0
 internal void AddMessage(Message message)
 {
     if (!this.bufferedChunks.TryEnqueue(this.receiveTimeout, message))
     {
         QuotaExceededException innerException = new QuotaExceededException(string.Format("Number of buffered chunks exceeded MaxBufferedChunks setting which is {0}. Consider increasing the setting or processing received data faster", this.bufferedChunks.MaxLength));
         throw new CommunicationException("Quota error while receiving message", innerException);
     }
 }
 public static Exception GetFaultException(string faultString, string via, string contentType)
 {
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound")
     {
         return(new EndpointNotFoundException(System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ContentTypeInvalid")
     {
         return(new ProtocolException(System.ServiceModel.SR.GetString("FramingContentTypeMismatch", new object[] { contentType, via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ServiceActivationFailed")
     {
         return(new ServiceActivationException(System.ServiceModel.SR.GetString("Hosting_ServiceActivationFailed", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ConnectionDispatchFailed")
     {
         return(new CommunicationException(System.ServiceModel.SR.GetString("Sharing_ConnectionDispatchFailed", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointUnavailable")
     {
         return(new EndpointNotFoundException(System.ServiceModel.SR.GetString("Sharing_EndpointUnavailable", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/MaxMessageSizeExceededFault")
     {
         Exception innerException = new QuotaExceededException(System.ServiceModel.SR.GetString("FramingMaxMessageSizeExceeded"));
         return(new CommunicationException(innerException.Message, innerException));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode")
     {
         return(new ProtocolException(System.ServiceModel.SR.GetString("FramingModeNotSupportedFault", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedVersion")
     {
         return(new ProtocolException(System.ServiceModel.SR.GetString("FramingVersionNotSupportedFault", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ContentTypeTooLong")
     {
         Exception exception2 = new QuotaExceededException(System.ServiceModel.SR.GetString("FramingContentTypeTooLongFault", new object[] { contentType }));
         return(new CommunicationException(exception2.Message, exception2));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ViaTooLong")
     {
         Exception exception3 = new QuotaExceededException(System.ServiceModel.SR.GetString("FramingViaTooLongFault", new object[] { via }));
         return(new CommunicationException(exception3.Message, exception3));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ServerTooBusy")
     {
         return(new ServerTooBusyException(System.ServiceModel.SR.GetString("ServerTooBusy", new object[] { via })));
     }
     if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UpgradeInvalid")
     {
         return(new ProtocolException(System.ServiceModel.SR.GetString("FramingUpgradeInvalid", new object[] { via })));
     }
     return(new ProtocolException(System.ServiceModel.SR.GetString("FramingFaultUnrecognized", new object[] { faultString })));
 }
        internal static Exception CreateMaxSentMessageSizeExceededException(long maxMessageSize)
        {
            string message = SR.Format(SR.MaxSentMessageSizeExceeded, maxMessageSize);
            Exception inner = new QuotaExceededException(message);

            if (WcfEventSource.Instance.MaxSentMessageSizeExceededIsEnabled())
            {
                WcfEventSource.Instance.MaxSentMessageSizeExceeded(message);
            }

            return new CommunicationException(message, inner);
        }
        public static Exception CreateMaxReceivedMessageSizeExceededException(long maxMessageSize)
        {
            string message = SR.Format(SR.MaxReceivedMessageSizeExceeded, maxMessageSize);
            Exception inner = new QuotaExceededException(message);

            if (TD.MaxReceivedMessageSizeExceededIsEnabled())
            {
                TD.MaxReceivedMessageSizeExceeded(message);
            }

            return new CommunicationException(message, inner);
        }
Exemple #11
0
        internal static Exception CreateMaxSentMessageSizeExceededException(long maxMessageSize)
        {
            string    message = SR.GetString(SR.MaxSentMessageSizeExceeded, maxMessageSize);
            Exception inner   = new QuotaExceededException(message);

            if (TD.MaxSentMessageSizeExceededIsEnabled())
            {
                TD.MaxSentMessageSizeExceeded(message);
            }

            return(new CommunicationException(message, inner));
        }
        public static Exception CreateMaxReceivedMessageSizeExceededException(long maxMessageSize)
        {
            string    message = string.Format(SRServiceModel.MaxReceivedMessageSizeExceeded, maxMessageSize);
            Exception inner   = new QuotaExceededException(message);

            if (WcfEventSource.Instance.MaxReceivedMessageSizeExceededIsEnabled())
            {
                WcfEventSource.Instance.MaxReceivedMessageSizeExceeded(message);
            }

            return(new CommunicationException(message, inner));
        }
Exemple #13
0
        private static void Deduct(string s, ref int maxSizeOfHeaders)
        {
            int num = s.Length * 2;

            if (num > maxSizeOfHeaders)
            {
                string    message        = System.ServiceModel.SR.GetString("XmlBufferQuotaExceeded");
                Exception innerException = new QuotaExceededException(message);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, innerException));
            }
            maxSizeOfHeaders -= num;
        }
Exemple #14
0
        internal static Exception CreateMaxSentMessageSizeExceededException(long maxMessageSize)
        {
            string    message = SR.Format(SR.MaxSentMessageSizeExceeded, maxMessageSize);
            Exception inner   = new QuotaExceededException(message);

            if (WcfEventSource.Instance.MaxSentMessageSizeExceededIsEnabled())
            {
                WcfEventSource.Instance.MaxSentMessageSizeExceeded(message);
            }

            return(new CommunicationException(message, inner));
        }
Exemple #15
0
        public static Exception CreateMaxReceivedMessageSizeExceededException(long maxMessageSize)
        {
            string    message = SR.Format(SR.MaxReceivedMessageSizeExceeded, maxMessageSize);
            Exception inner   = new QuotaExceededException(message);

            if (TD.MaxReceivedMessageSizeExceededIsEnabled())
            {
                TD.MaxReceivedMessageSizeExceeded(message);
            }

            return(new CommunicationException(message, inner));
        }
Exemple #16
0
        private void ThrowMaxReceivedMessageSizeExceeded()
        {
            if (WcfEventSource.Instance.MaxReceivedMessageSizeExceededIsEnabled())
            {
                WcfEventSource.Instance.MaxReceivedMessageSizeExceeded(SR.Format(SR.MaxReceivedMessageSizeExceeded, _factory.MaxReceivedMessageSize));
            }

            string    message = SR.Format(SR.MaxReceivedMessageSizeExceeded, _factory.MaxReceivedMessageSize);
            Exception inner   = new QuotaExceededException(message);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
        }
 private void ThrowMaxReceivedMessageSizeExceeded()
 {
     if (this.isRequest)
     {
         this.ThrowHttpProtocolException(System.ServiceModel.SR.GetString("MaxReceivedMessageSizeExceeded", new object[] { this.settings.MaxReceivedMessageSize }), HttpStatusCode.BadRequest);
     }
     else
     {
         string    message        = System.ServiceModel.SR.GetString("MaxReceivedMessageSizeExceeded", new object[] { this.settings.MaxReceivedMessageSize });
         Exception innerException = new QuotaExceededException(message);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, innerException));
     }
 }
        //  size:   sending => the size of the data being sent
        //          Receiving => the max message size we can receive
        //  remoteEndPoint: remote endpoint reported when error occured
        static Exception ConvertNetworkError(SocketException socketException, int size, TransferDirection direction, int timeToLive)
        {
            Exception result = null;

            if (socketException.ErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE)
            {
                //This would likely indicate a bug in our ref-counting
                //for instance, a channel is closing the socket multiple times...
                Fx.Assert("The socket appears to have been closed unexpectedly.  This probably indicates incorrect ref counting (i.e. a channel is closing the socket multiple times)");
                result = new CommunicationObjectAbortedException(socketException.Message, socketException);
            }
            else
            {
                string errorMessage;
                switch (socketException.SocketErrorCode)
                {
                case SocketError.MessageSize:     //10040
                    errorMessage = (direction == TransferDirection.Send ? SR.UdpMaxMessageSendSizeExceeded(size) : SR.MaxReceivedMessageSizeExceeded(size));
                    Exception inner = new QuotaExceededException(errorMessage, socketException);
                    result = new ProtocolException(errorMessage, inner);
                    break;

                case SocketError.NetworkReset:     //10052
                    //ICMP: Time Exceeded (TTL expired)
                    //see http://tools.ietf.org/html/rfc792
                    result = new CommunicationException(SR.IcmpTimeExpired(timeToLive), socketException);
                    break;

                case SocketError.ConnectionReset:     //10054
                    //ICMP: Destination Unreachable (target host/port/etc not reachable)
                    //see http://tools.ietf.org/html/rfc792
                    result = new CommunicationException(SR.IcmpDestinationUnreachable, socketException);
                    break;

                default:
                    errorMessage = (direction == TransferDirection.Send ? SR.UdpSendException : SR.UdpReceiveException);
                    result       = new CommunicationException(errorMessage, socketException);
                    break;
                }
            }

            Fx.Assert(result != null, "we should never return null");
            return(result);
        }
        public static Exception GetFaultException(string faultString, string via, string contentType)
        {
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound")
            {
                string   endpointNotFound = Resources.EndpointNotFound;
                object[] objArray         = new object[] { via };
                return(new EndpointNotFoundException(Microsoft.ServiceBus.SR.GetString(endpointNotFound, objArray)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ContentTypeInvalid")
            {
                string   framingContentTypeMismatch = Resources.FramingContentTypeMismatch;
                object[] objArray1 = new object[] { contentType, via };
                return(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingContentTypeMismatch, objArray1)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ServiceActivationFailed")
            {
                string   hostingServiceActivationFailed = Resources.Hosting_ServiceActivationFailed;
                object[] objArray2 = new object[] { via };
                return(new ServiceActivationException(Microsoft.ServiceBus.SR.GetString(hostingServiceActivationFailed, objArray2)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ConnectionDispatchFailed")
            {
                string   sharingConnectionDispatchFailed = Resources.Sharing_ConnectionDispatchFailed;
                object[] objArray3 = new object[] { via };
                return(new CommunicationException(Microsoft.ServiceBus.SR.GetString(sharingConnectionDispatchFailed, objArray3)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointUnavailable")
            {
                string   sharingEndpointUnavailable = Resources.Sharing_EndpointUnavailable;
                object[] objArray4 = new object[] { via };
                return(new EndpointNotFoundException(Microsoft.ServiceBus.SR.GetString(sharingEndpointUnavailable, objArray4)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/MaxMessageSizeExceededFault")
            {
                Exception quotaExceededException = new QuotaExceededException(Microsoft.ServiceBus.SR.GetString(Resources.FramingMaxMessageSizeExceeded, new object[0]));
                return(new CommunicationException(quotaExceededException.Message, quotaExceededException));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode")
            {
                string   framingModeNotSupportedFault = Resources.FramingModeNotSupportedFault;
                object[] objArray5 = new object[] { via };
                return(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingModeNotSupportedFault, objArray5)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedVersion")
            {
                string   framingVersionNotSupportedFault = Resources.FramingVersionNotSupportedFault;
                object[] objArray6 = new object[] { via };
                return(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingVersionNotSupportedFault, objArray6)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ContentTypeTooLong")
            {
                string    framingContentTypeTooLongFault = Resources.FramingContentTypeTooLongFault;
                object[]  objArray7 = new object[] { contentType };
                Exception exception = new QuotaExceededException(Microsoft.ServiceBus.SR.GetString(framingContentTypeTooLongFault, objArray7));
                return(new CommunicationException(exception.Message, exception));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ViaTooLong")
            {
                string    framingViaTooLongFault = Resources.FramingViaTooLongFault;
                object[]  objArray8 = new object[] { via };
                Exception quotaExceededException1 = new QuotaExceededException(Microsoft.ServiceBus.SR.GetString(framingViaTooLongFault, objArray8));
                return(new CommunicationException(quotaExceededException1.Message, quotaExceededException1));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/ServerTooBusy")
            {
                string   serverTooBusy = Resources.ServerTooBusy;
                object[] objArray9     = new object[] { via };
                return(new ServerTooBusyException(Microsoft.ServiceBus.SR.GetString(serverTooBusy, objArray9)));
            }
            if (faultString == "http://schemas.microsoft.com/ws/2006/05/framing/faults/UpgradeInvalid")
            {
                string   framingUpgradeInvalid = Resources.FramingUpgradeInvalid;
                object[] objArray10            = new object[] { via };
                return(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingUpgradeInvalid, objArray10)));
            }
            string framingFaultUnrecognized = Resources.FramingFaultUnrecognized;

            object[] objArray11 = new object[] { faultString };
            return(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingFaultUnrecognized, objArray11)));
        }
Exemple #20
0
        private void ThrowMaxReceivedMessageSizeExceeded()
        {
            if (TD.MaxReceivedMessageSizeExceededIsEnabled())
            {
                TD.MaxReceivedMessageSizeExceeded(SR.Format(SR.MaxReceivedMessageSizeExceeded, _settings.MaxReceivedMessageSize));
            }

            if (_isRequest)
            {
                ThrowHttpProtocolException(SR.Format(SR.MaxReceivedMessageSizeExceeded, _settings.MaxReceivedMessageSize), HttpStatusCode.RequestEntityTooLarge);
            }
            else
            {
                string message = SR.Format(SR.MaxReceivedMessageSizeExceeded, _settings.MaxReceivedMessageSize);
                Exception inner = new QuotaExceededException(message);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
            }
        }
            private ArraySegment <byte> ExtractSessionInformationFromMessage(ArraySegment <byte> messageData)
            {
                int num3;
                int num4;

                if (this.isReaderSessionInvalid)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataException(System.ServiceModel.SR.GetString("BinaryEncoderSessionInvalid")));
                }
                byte[] array = messageData.Array;
                bool   flag  = true;

                try
                {
                    IntDecoder decoder = new IntDecoder();
                    int        num2    = decoder.Decode(array, messageData.Offset, messageData.Count);
                    int        num     = decoder.Value;
                    if (num > messageData.Count)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataException(System.ServiceModel.SR.GetString("BinaryEncoderSessionMalformed")));
                    }
                    num3 = (messageData.Offset + num2) + num;
                    num4 = (messageData.Count - num2) - num;
                    if (num4 < 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataException(System.ServiceModel.SR.GetString("BinaryEncoderSessionMalformed")));
                    }
                    if (num > 0)
                    {
                        if (num > this.remainingReaderSessionSize)
                        {
                            string    message        = System.ServiceModel.SR.GetString("BinaryEncoderSessionTooLarge", new object[] { this.maxSessionSize });
                            Exception innerException = new QuotaExceededException(message);
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, innerException));
                        }
                        this.remainingReaderSessionSize -= num;
                        int size   = num;
                        int offset = messageData.Offset + num2;
                        while (size > 0)
                        {
                            decoder.Reset();
                            int num7  = decoder.Decode(array, offset, size);
                            int count = decoder.Value;
                            offset += num7;
                            size   -= num7;
                            if (count > size)
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataException(System.ServiceModel.SR.GetString("BinaryEncoderSessionMalformed")));
                            }
                            string str2 = Encoding.UTF8.GetString(array, offset, count);
                            offset += count;
                            size   -= count;
                            this.readerSession.Add(this.idCounter, str2);
                            this.idCounter++;
                        }
                    }
                    flag = false;
                }
                finally
                {
                    if (flag)
                    {
                        this.isReaderSessionInvalid = true;
                    }
                }
                return(new ArraySegment <byte>(array, num3, num4));
            }
        private void ThrowMaxReceivedMessageSizeExceeded()
        {
            if (TD.MaxReceivedMessageSizeExceededIsEnabled())
            {
                TD.MaxReceivedMessageSizeExceeded(SR.Format(SR.MaxReceivedMessageSizeExceeded, _factory.MaxReceivedMessageSize));
            }

            string message = SR.Format(SR.MaxReceivedMessageSizeExceeded, _factory.MaxReceivedMessageSize);
            Exception inner = new QuotaExceededException(message);
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(message, inner));
        }