コード例 #1
0
 private void aqUALe(System.ComponentModel.Design.ComponentRenameEventHandler ddcmL, System.ComponentModel.RunWorkerCompletedEventHandler fITc, System.Web.UI.WebControls.DataGridCommandEventHandler EmBq, System.Web.UI.FileLevelControlBuilderAttribute sPPKp)
 {
     System.Web.Configuration.SystemWebCachingSectionGroup  jQz  = new System.Web.Configuration.SystemWebCachingSectionGroup();
     System.Web.UI.WebControls.AutoGeneratedFieldProperties ebpp = new System.Web.UI.WebControls.AutoGeneratedFieldProperties();
     System.IndexOutOfRangeException EGU    = new System.IndexOutOfRangeException("LxykR");
     System.Windows.Forms.Form       FteiWM = new System.Windows.Forms.Form();
     System.Runtime.InteropServices.GuidAttribute                 ZtMnwg  = new System.Runtime.InteropServices.GuidAttribute("SecJ");
     System.Web.UI.SessionPageStatePersister                      xqU     = new System.Web.UI.SessionPageStatePersister(new System.Web.UI.Page());
     System.Runtime.CompilerServices.CallConvThiscall             PBZYvp  = new System.Runtime.CompilerServices.CallConvThiscall();
     System.Runtime.Remoting.Metadata.SoapTypeAttribute           xiF     = new System.Runtime.Remoting.Metadata.SoapTypeAttribute();
     System.Web.UI.WebControls.WebParts.PersonalizationDictionary ryQoeKu = new System.Web.UI.WebControls.WebParts.PersonalizationDictionary(960700150);
     System.Web.HttpCompileException GNlirN = new System.Web.HttpCompileException("wtD", new System.Exception());
     System.Windows.Forms.SplitterCancelEventArgs                   EHI    = new System.Windows.Forms.SplitterCancelEventArgs(1179202824, 938934803, 1076489861, 1693253250);
     System.Collections.CaseInsensitiveComparer                     WeJLuo = new System.Collections.CaseInsensitiveComparer();
     System.Web.UI.WebControls.FileUpload                           dGBt   = new System.Web.UI.WebControls.FileUpload();
     System.Data.SqlTypes.TypeBinarySchemaImporterExtension         Poy    = new System.Data.SqlTypes.TypeBinarySchemaImporterExtension();
     System.ComponentModel.InvalidAsynchronousStateException        YKPisM = new System.ComponentModel.InvalidAsynchronousStateException("Njr");
     System.Windows.Forms.DataGridViewLinkCell                      WkW    = new System.Windows.Forms.DataGridViewLinkCell();
     System.Web.UI.WebControls.RepeatInfo                           mab    = new System.Web.UI.WebControls.RepeatInfo();
     System.Windows.Forms.PropertyGridInternal.PropertyGridCommands mDpTr  = new System.Windows.Forms.PropertyGridInternal.PropertyGridCommands();
     System.Net.Configuration.AuthenticationModulesSection          jegyMl = new System.Net.Configuration.AuthenticationModulesSection();
     System.Data.SqlTypes.TypeCharSchemaImporterExtension           vPj    = new System.Data.SqlTypes.TypeCharSchemaImporterExtension();
     System.ParamArrayAttribute jrYvIh = new System.ParamArrayAttribute();
     System.Diagnostics.SymbolStore.SymDocumentType RJHOPE = new System.Diagnostics.SymbolStore.SymDocumentType();
     System.CodeDom.Compiler.CompilerResults        ptlrlx = new System.CodeDom.Compiler.CompilerResults(new System.CodeDom.Compiler.TempFileCollection());
 }
コード例 #2
0
        public void Verify_ExceptionWasThrownButOfWrongType_ThrowsException()
        {
            var constraint = CreateConstraint(typeof(ArgumentNullException));
            var actualException = new IndexOutOfRangeException();

            NUnit.Framework.Assert.Throws<AssertFailedException>(
                () => constraint.Verify(actualException));
        }
 public void If_Message_And_Inner_Exception_Is_Passed_Them_Should_Be_Stored_In_Properties()
 {
     String exceptionMessage = "ExceptionMessage";
     var innerEx = new IndexOutOfRangeException();
     var sut = new ImageFolderNotSpecifiedException(exceptionMessage,innerEx);
     Assert.AreEqual(exceptionMessage, sut.Message);
     Assert.AreEqual(innerEx,sut.InnerException);
 }
コード例 #4
0
        public void GetEventFragments_PreservesException_WhenSplitting()
        {
            _logEventInfo.Message = StringGenerator.BuildRandomString(MaxSize + 1);
            var exception = new IndexOutOfRangeException("My exception");
            _logEventInfo.Exception = exception;

            List<LogEventInfo> result = _splitter.GetEventFragments(_logEventInfo);

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0].Exception, Is.EqualTo(exception));
            Assert.That(result[1].Exception, Is.EqualTo(exception));
        }
コード例 #5
0
ファイル: Qa.cs プロジェクト: erisonliang/qizmt
 public static StringSlice Prepare(StringSlice ss, int offset, int length)
 {
     if (offset < 0 || length < 0 || offset + length > ss.length)
     {
         IndexOutOfRangeException ior = new IndexOutOfRangeException("StringSlice.Prepare(StringSlice{offset=" + ss.offset + ", length=" + ss.length + "}, offset=" + offset + ", length=" + length + ")");
         throw new ArgumentOutOfRangeException("Specified argument was out of the range of valid values. Index out of bounds: " + ior.Message, ior); // Preserve the old exception type.
     }
     StringSlice ssnew;
     ssnew.str = ss.str;
     ssnew.offset = ss.offset + offset;
     ssnew.length = length;
     return ssnew;
 }
コード例 #6
0
ファイル: Stack.cs プロジェクト: dec-k/IN710-keigdl1
 //Returns the most recently added item in the stack, but doesn't remove it.
 public String Peek()
 {
     try
     {
         //create a string, used to show user output.
         string mostRecentItem = stack[iterator - 1];
         return mostRecentItem;
     }
     catch (IndexOutOfRangeException)
     {
         System.IndexOutOfRangeException exString = new System.IndexOutOfRangeException("You have attempted to peek an empty stack.");
         throw exString;
     }
 }
コード例 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public override void Write( Stream output )
        {
            BinaryWriter bw = new BinaryWriter( output );
            bw.Write( ( byte )_FilterType );

            if ( _MatrixValues.Count != 20 )
            {
                IndexOutOfRangeException e = new IndexOutOfRangeException( "_MatrixValues does not have 20 entries, does have " + _MatrixValues.Count.ToString( "d" ) );
                throw e;
            }

            for ( int i = 0; i < 20; i++ )
            {
                bw.Write( _MatrixValues[ i ] );
            }
        }
コード例 #8
0
        public bool RemoveAt(int index)
        {
            bool removeAt = false;

            try
            {
                if (index >= 0 && index < count)
                {
                    T[] reducedArray = new T[count];
                    int reducedCount = 0;
                    for (int i = 0; i < count; i++)
                    {
                        if (i < index)
                        {
                            reducedArray[i] = newArray[i];
                            reducedCount++;
                        }
                        else if (i > index)
                        {
                            reducedArray[i - 1] = newArray[i];
                            reducedCount++;
                        }
                    }
                    if (count == reducedCount + 1)
                    {
                        removeAt = true;
                    }
                    newArray = reducedArray;
                    count--;
                }
            }
            catch
            {
                System.IndexOutOfRangeException indexOutOfRange = new System.IndexOutOfRangeException("Index cannot be out of range");
                throw indexOutOfRange;
            }
            return(removeAt);
        }
コード例 #9
0
        public void GetEventFragments_PreservesOrIncrementsTimeStapm_WhenSplitting()
        {
            _logEventInfo.Message = StringGenerator.BuildRandomString(MaxSize + 1);
            var exception = new IndexOutOfRangeException("My exception");
            _logEventInfo.TimeStamp = DateTime.UtcNow;

            List<LogEventInfo> result = _splitter.GetEventFragments(_logEventInfo);

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0].TimeStamp, Is.GreaterThanOrEqualTo(_logEventInfo.TimeStamp));
            Assert.That(result[1].TimeStamp, Is.GreaterThanOrEqualTo(result[0].TimeStamp));
            Assert.That(result[1].TimeStamp, Is.GreaterThanOrEqualTo(_logEventInfo.TimeStamp));
        }
コード例 #10
0
ファイル: AppyRouterTests.cs プロジェクト: bberak/Appy
        public void Verify_IndexOutOfRangeException_IsCaaughtAndThrown()
        {
            IndexOutOfRangeException ex = new IndexOutOfRangeException();

            Router.TryHandleException(ex);
        }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public override void Write( Stream output )
        {
            BinaryWriter bw = new BinaryWriter( output );
            bw.Write( ( byte )_FilterType );

            bw.Write( _MatrixX );
            bw.Write( _MatrixY );
            bw.Write( _DivisorFLOAT );
            bw.Write( _BiasFLOAT );

            if ( _MatrixValues.Count != ( _MatrixX * _MatrixY ) )
            {
                IndexOutOfRangeException e = new IndexOutOfRangeException( "_MatrixValues does not have " + (_MatrixX*_MatrixY).ToString("d") + " entries, does have " + _MatrixValues.Count.ToString( "d" ) );
                throw e;
            }

            for ( int i = 0; i < _MatrixValues.Count; i++ )
            {
                bw.Write( _MatrixValues[ i ] );
            }

            _DefaultColor.Write( output );
            BitStream bits = new BitStream( output );
            bits.WriteBits( 6, 0 );
            bits.WriteBits( 1, ( _Clamp ? 1 : 0 ) );
            bits.WriteBits( 1, ( _PreserveAlpha ? 1 : 0 ) );
            bits.WriteFlush();
        }
コード例 #12
0
ファイル: ExceptionHelpers.cs プロジェクト: justinvp/corert
        /// <summary>
        /// This does a mapping from hr to the exception and also takes care of making default exception in case of classic COM as COMException.
        /// and in winrt and marshal APIs as Exception.
        /// </summary>
        /// <param name="errorCode"></param>
        /// <param name="message"></param>
        /// <param name="createCOMException"></param>
        /// <returns></returns>
        internal static Exception GetMappingExceptionForHR(int errorCode, string message, bool createCOMException, bool hasErrorInfo)
        {
            if (errorCode >= 0)
            {
                return null;
            }

            Exception exception = null;

            bool shouldDisplayHR = false;

            switch (errorCode)
            {
                case __HResults.COR_E_NOTFINITENUMBER: // NotFiniteNumberException
                case __HResults.COR_E_ARITHMETIC:
                    exception = new ArithmeticException();
                    break;
                case __HResults.COR_E_ARGUMENT:
                case unchecked((int)0x800A01C1):
                case unchecked((int)0x800A01C2):
                case __HResults.CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT:
                    exception = new ArgumentException();

                    if (errorCode != __HResults.COR_E_ARGUMENT)
                        shouldDisplayHR = true;

                    break;
                case __HResults.E_BOUNDS:
                case __HResults.COR_E_ARGUMENTOUTOFRANGE:
                case __HResults.ERROR_NO_UNICODE_TRANSLATION:
                    exception = new ArgumentOutOfRangeException();

                    if (errorCode != __HResults.COR_E_ARGUMENTOUTOFRANGE)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_ARRAYTYPEMISMATCH:
                    exception = new ArrayTypeMismatchException();
                    break;
                case __HResults.COR_E_BADIMAGEFORMAT:
                case __HResults.CLDB_E_FILE_OLDVER:
                case __HResults.CLDB_E_INDEX_NOTFOUND:
                case __HResults.CLDB_E_FILE_CORRUPT:
                case __HResults.COR_E_NEWER_RUNTIME:
                case __HResults.COR_E_ASSEMBLYEXPECTED:
                case __HResults.ERROR_BAD_EXE_FORMAT:
                case __HResults.ERROR_EXE_MARKED_INVALID:
                case __HResults.CORSEC_E_INVALID_IMAGE_FORMAT:
                case __HResults.ERROR_NOACCESS:
                case __HResults.ERROR_INVALID_ORDINAL:
                case __HResults.ERROR_INVALID_DLL:
                case __HResults.ERROR_FILE_CORRUPT:
                case __HResults.COR_E_LOADING_REFERENCE_ASSEMBLY:
                case __HResults.META_E_BAD_SIGNATURE:
                    exception = new BadImageFormatException();

                    // Always show HR for BadImageFormatException
                    shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_CUSTOMATTRIBUTEFORMAT:
                    exception = new FormatException();
                    break; // CustomAttributeFormatException
                case __HResults.COR_E_DATAMISALIGNED:
                    exception = InteropExtensions.CreateDataMisalignedException(message); // TODO: Do we need to add msg here?
                    break;
                case __HResults.COR_E_DIVIDEBYZERO:
                case __HResults.CTL_E_DIVISIONBYZERO:
                    exception = new DivideByZeroException();

                    if (errorCode != __HResults.COR_E_DIVIDEBYZERO)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_DLLNOTFOUND:
#if ENABLE_WINRT
                    exception = new DllNotFoundException();
#endif
                    break;
                case __HResults.COR_E_DUPLICATEWAITOBJECT:
                    exception = new ArgumentException();
                    break; // DuplicateWaitObjectException
                case __HResults.COR_E_ENDOFSTREAM:
                case unchecked((int)0x800A003E):
                    exception = new System.IO.EndOfStreamException();

                    if (errorCode != __HResults.COR_E_ENDOFSTREAM)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_TYPEACCESS: // TypeAccessException
                case __HResults.COR_E_ENTRYPOINTNOTFOUND:
                    exception = new TypeLoadException();

                    break; // EntryPointNotFoundException
                case __HResults.COR_E_EXCEPTION:
                    exception = new Exception();
                    break;
                case __HResults.COR_E_DIRECTORYNOTFOUND:
                case __HResults.STG_E_PATHNOTFOUND:
                case __HResults.CTL_E_PATHNOTFOUND:
                    exception = new System.IO.DirectoryNotFoundException();

                    if (errorCode != __HResults.COR_E_DIRECTORYNOTFOUND)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_FILELOAD:
                case __HResults.FUSION_E_INVALID_PRIVATE_ASM_LOCATION:
                case __HResults.FUSION_E_SIGNATURE_CHECK_FAILED:
                case __HResults.FUSION_E_LOADFROM_BLOCKED:
                case __HResults.FUSION_E_CACHEFILE_FAILED:
                case __HResults.FUSION_E_ASM_MODULE_MISSING:
                case __HResults.FUSION_E_INVALID_NAME:
                case __HResults.FUSION_E_PRIVATE_ASM_DISALLOWED:
                case __HResults.FUSION_E_HOST_GAC_ASM_MISMATCH:
                case __HResults.COR_E_MODULE_HASH_CHECK_FAILED:
                case __HResults.FUSION_E_REF_DEF_MISMATCH:
                case __HResults.SECURITY_E_INCOMPATIBLE_SHARE:
                case __HResults.SECURITY_E_INCOMPATIBLE_EVIDENCE:
                case __HResults.SECURITY_E_UNVERIFIABLE:
                case __HResults.COR_E_FIXUPSINEXE:
                case __HResults.ERROR_TOO_MANY_OPEN_FILES:
                case __HResults.ERROR_SHARING_VIOLATION:
                case __HResults.ERROR_LOCK_VIOLATION:
                case __HResults.ERROR_OPEN_FAILED:
                case __HResults.ERROR_DISK_CORRUPT:
                case __HResults.ERROR_UNRECOGNIZED_VOLUME:
                case __HResults.ERROR_DLL_INIT_FAILED:
                case __HResults.FUSION_E_CODE_DOWNLOAD_DISABLED:
                case __HResults.CORSEC_E_MISSING_STRONGNAME:
                case __HResults.MSEE_E_ASSEMBLYLOADINPROGRESS:
                case __HResults.ERROR_FILE_INVALID:
                    exception = new System.IO.FileLoadException();

                    shouldDisplayHR = true;
                    break;
                case __HResults.COR_E_PATHTOOLONG:
                    exception = new System.IO.PathTooLongException();
                    break;
                case __HResults.COR_E_IO:
                case __HResults.CTL_E_DEVICEIOERROR:
                case unchecked((int)0x800A793C):
                case unchecked((int)0x800A793D):
                    exception = new System.IO.IOException();

                    if (errorCode != __HResults.COR_E_IO)
                        shouldDisplayHR = true;

                    break;
                case __HResults.ERROR_FILE_NOT_FOUND:
                case __HResults.ERROR_MOD_NOT_FOUND:
                case __HResults.ERROR_INVALID_NAME:
                case __HResults.CTL_E_FILENOTFOUND:
                case __HResults.ERROR_BAD_NET_NAME:
                case __HResults.ERROR_BAD_NETPATH:
                case __HResults.ERROR_NOT_READY:
                case __HResults.ERROR_WRONG_TARGET_NAME:
                case __HResults.INET_E_UNKNOWN_PROTOCOL:
                case __HResults.INET_E_CONNECTION_TIMEOUT:
                case __HResults.INET_E_CANNOT_CONNECT:
                case __HResults.INET_E_RESOURCE_NOT_FOUND:
                case __HResults.INET_E_OBJECT_NOT_FOUND:
                case __HResults.INET_E_DOWNLOAD_FAILURE:
                case __HResults.INET_E_DATA_NOT_AVAILABLE:
                case __HResults.ERROR_DLL_NOT_FOUND:
                case __HResults.CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW:
                case __HResults.CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH:
                case __HResults.CLR_E_BIND_ASSEMBLY_NOT_FOUND:
                    exception = new System.IO.FileNotFoundException();

                    shouldDisplayHR = true;
                    break;
                case __HResults.COR_E_FORMAT:
                    exception = new FormatException();
                    break;
                case __HResults.COR_E_INDEXOUTOFRANGE:
                case unchecked((int)0x800a0009):
                    exception = new IndexOutOfRangeException();

                    if (errorCode != __HResults.COR_E_INDEXOUTOFRANGE)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_INVALIDCAST:
                    exception = new InvalidCastException();
                    break;
                case __HResults.COR_E_INVALIDCOMOBJECT:
                    exception = new InvalidComObjectException();
                    break;
                case __HResults.COR_E_INVALIDOLEVARIANTTYPE:
                    exception = new InvalidOleVariantTypeException();
                    break;
                case __HResults.COR_E_INVALIDOPERATION:
                case __HResults.E_ILLEGAL_STATE_CHANGE:
                case __HResults.E_ILLEGAL_METHOD_CALL:
                case __HResults.E_ILLEGAL_DELEGATE_ASSIGNMENT:
                case __HResults.APPMODEL_ERROR_NO_PACKAGE:
                    exception = new InvalidOperationException();

                    if (errorCode != __HResults.COR_E_INVALIDOPERATION)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_MARSHALDIRECTIVE:
                    exception = new MarshalDirectiveException();
                    break;
                case __HResults.COR_E_METHODACCESS: // MethodAccessException
                case __HResults.META_E_CA_FRIENDS_SN_REQUIRED: // MethodAccessException
                case __HResults.COR_E_FIELDACCESS:
                case __HResults.COR_E_MEMBERACCESS:
                    exception = new MemberAccessException();

                    if (errorCode != __HResults.COR_E_METHODACCESS)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_MISSINGFIELD: // MissingFieldException
                case __HResults.COR_E_MISSINGMETHOD: // MissingMethodException
                case __HResults.COR_E_MISSINGMEMBER:
                case unchecked((int)0x800A01CD):
                    exception = new MissingMemberException();
                    break;
                case __HResults.COR_E_MISSINGMANIFESTRESOURCE:
                    exception = new System.Resources.MissingManifestResourceException();
                    break;
                case __HResults.COR_E_NOTSUPPORTED:
                case unchecked((int)0x800A01B6):
                case unchecked((int)0x800A01BD):
                case unchecked((int)0x800A01CA):
                case unchecked((int)0x800A01CB):
                    exception = new NotSupportedException();

                    if (errorCode != __HResults.COR_E_NOTSUPPORTED)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_NULLREFERENCE:
                    exception = new NullReferenceException();
                    break;
                case __HResults.COR_E_OBJECTDISPOSED:
                case __HResults.RO_E_CLOSED:
                    // No default constructor
                    exception = new ObjectDisposedException(String.Empty);
                    break;
                case __HResults.COR_E_OPERATIONCANCELED:
#if ENABLE_WINRT
                    exception = new OperationCanceledException();
#endif
                    break;
                case __HResults.COR_E_OVERFLOW:
                case __HResults.CTL_E_OVERFLOW:
                    exception = new OverflowException();
                    break;
                case __HResults.COR_E_PLATFORMNOTSUPPORTED:
                    exception = new PlatformNotSupportedException(message);
                    break;
                case __HResults.COR_E_RANK:
                    exception = new RankException();
                    break;
                case __HResults.COR_E_REFLECTIONTYPELOAD:
#if ENABLE_WINRT
                    exception = new System.Reflection.ReflectionTypeLoadException(null, null);
#endif
                    break;
                case __HResults.COR_E_SECURITY:
                case __HResults.CORSEC_E_INVALID_STRONGNAME:
                case __HResults.CTL_E_PERMISSIONDENIED:
                case unchecked((int)0x800A01A3):
                case __HResults.CORSEC_E_INVALID_PUBLICKEY:
                case __HResults.CORSEC_E_SIGNATURE_MISMATCH:
                    exception = new System.Security.SecurityException();
                    break;
                case __HResults.COR_E_SAFEARRAYRANKMISMATCH:
                    exception = new SafeArrayRankMismatchException();
                    break;
                case __HResults.COR_E_SAFEARRAYTYPEMISMATCH:
                    exception = new SafeArrayTypeMismatchException();
                    break;
                case __HResults.COR_E_SERIALIZATION:
                    exception = new System.Runtime.Serialization.SerializationException(message);
                    break;
                case __HResults.COR_E_SYNCHRONIZATIONLOCK:
                    exception = new System.Threading.SynchronizationLockException();
                    break;
                case __HResults.COR_E_TARGETINVOCATION:
                    exception = new System.Reflection.TargetInvocationException(null);
                    break;
                case __HResults.COR_E_TARGETPARAMCOUNT:
                    exception = new System.Reflection.TargetParameterCountException();
                    break;
                case __HResults.COR_E_TYPEINITIALIZATION:
                    exception = InteropExtensions.CreateTypeInitializationException(message);
                    break;
                case __HResults.COR_E_TYPELOAD:
                case __HResults.RO_E_METADATA_NAME_NOT_FOUND:
                case __HResults.CLR_E_BIND_TYPE_NOT_FOUND:
                    exception = new TypeLoadException();

                    if (errorCode != __HResults.COR_E_TYPELOAD)
                        shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_UNAUTHORIZEDACCESS:
                case __HResults.CTL_E_PATHFILEACCESSERROR:
                case unchecked((int)0x800A014F):
                    exception = new UnauthorizedAccessException();

                    shouldDisplayHR = true;

                    break;
                case __HResults.COR_E_VERIFICATION:
                    exception = new System.Security.VerificationException();
                    break;
                case __HResults.E_NOTIMPL:
                    exception = new NotImplementedException();
                    break;
                case __HResults.E_OUTOFMEMORY:
                case __HResults.CTL_E_OUTOFMEMORY:
                case unchecked((int)0x800A7919):
                    exception = new OutOfMemoryException();

                    if (errorCode != __HResults.E_OUTOFMEMORY)
                        shouldDisplayHR = true;

                    break;
#if ENABLE_WINRT
                case __HResults.E_XAMLPARSEFAILED:
                    exception = ConstructExceptionUsingReflection(
                        "Windows.UI.Xaml.Markup.XamlParseException, System.Runtime.WindowsRuntime.UI.Xaml, Version=4.0.0.0",
                        message);
                    break;
                case __HResults.E_ELEMENTNOTAVAILABLE:
                    exception = ConstructExceptionUsingReflection(
                        "Windows.UI.Xaml.Automation.ElementNotAvailableException, System.Runtime.WindowsRuntime.UI.Xaml, Version=4.0.0.0",
                        message);
                    break;
                case __HResults.E_ELEMENTNOTENABLED:
                    exception = ConstructExceptionUsingReflection(
                        "Windows.UI.Xaml.Automation.ElementNotEnabledException, System.Runtime.WindowsRuntime.UI.Xaml, Version=4.0.0.0", 
                        message);
                    break;
                case __HResults.E_LAYOUTCYCLE:
                    exception = ConstructExceptionUsingReflection(
                        "Windows.UI.Xaml.LayoutCycleException, System.Runtime.WindowsRuntime.UI.Xaml, Version=4.0.0.0", 
                        message);
                    break;
#endif // ENABLE_WINRT
                case __HResults.COR_E_AMBIGUOUSMATCH: // AmbiguousMatchException
                case __HResults.COR_E_APPLICATION: // ApplicationException
                case __HResults.COR_E_APPDOMAINUNLOADED: // AppDomainUnloadedException
                case __HResults.COR_E_CANNOTUNLOADAPPDOMAIN: // CannotUnloadAppDomainException
                case __HResults.COR_E_CODECONTRACTFAILED: // ContractException
                case __HResults.COR_E_CONTEXTMARSHAL: // ContextMarshalException
                case __HResults.CORSEC_E_CRYPTO: // CryptographicException
                case __HResults.CORSEC_E_CRYPTO_UNEX_OPER: // CryptographicUnexpectedOperationException
                case __HResults.COR_E_EXECUTIONENGINE: // ExecutionEngineException
                case __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK: // InsufficientExecutionStackException
                case __HResults.COR_E_INVALIDFILTERCRITERIA: // InvalidFilterCriteriaException
                case __HResults.COR_E_INVALIDPROGRAM: // InvalidProgramException
                case __HResults.COR_E_MULTICASTNOTSUPPORTED: // MulticastNotSupportedException
                case __HResults.COR_E_REMOTING: // RemotingException
                case __HResults.COR_E_RUNTIMEWRAPPED: // RuntimeWrappedException
                case __HResults.COR_E_SERVER: // ServerException
                case __HResults.COR_E_STACKOVERFLOW: // StackOverflowException
                case __HResults.CTL_E_OUTOFSTACKSPACE: // StackOverflowException
                case __HResults.COR_E_SYSTEM: // SystemException
                case __HResults.COR_E_TARGET: // TargetException
                case __HResults.COR_E_THREADABORTED: // TargetException
                case __HResults.COR_E_THREADINTERRUPTED: // ThreadInterruptedException
                case __HResults.COR_E_THREADSTATE: // ThreadStateException
                case __HResults.COR_E_THREADSTART: // ThreadStartException
                case __HResults.COR_E_TYPEUNLOADED: // TypeUnloadedException
                case __HResults.CORSEC_E_POLICY_EXCEPTION: // PolicyException
                case __HResults.CORSEC_E_NO_EXEC_PERM: // PolicyException
                case __HResults.CORSEC_E_MIN_GRANT_FAIL: // PolicyException
                case __HResults.CORSEC_E_XMLSYNTAX: // XmlSyntaxException
                case __HResults.ISS_E_ALLOC_TOO_LARGE: // IsolatedStorageException
                case __HResults.ISS_E_BLOCK_SIZE_TOO_SMALL: // IsolatedStorageException
                case __HResults.ISS_E_CALLER: // IsolatedStorageException
                case __HResults.ISS_E_CORRUPTED_STORE_FILE: // IsolatedStorageException
                case __HResults.ISS_E_CREATE_DIR: // IsolatedStorageException
                case __HResults.ISS_E_CREATE_MUTEX: // IsolatedStorageException
                case __HResults.ISS_E_DEPRECATE: // IsolatedStorageException
                case __HResults.ISS_E_FILE_NOT_MAPPED: // IsolatedStorageException
                case __HResults.ISS_E_FILE_WRITE: // IsolatedStorageException
                case __HResults.ISS_E_GET_FILE_SIZE: // IsolatedStorageException
                case __HResults.ISS_E_ISOSTORE: // IsolatedStorageException
                case __HResults.ISS_E_LOCK_FAILED: // IsolatedStorageException
                case __HResults.ISS_E_MACHINE: // IsolatedStorageException
                case __HResults.ISS_E_MACHINE_DACL: // IsolatedStorageException
                case __HResults.ISS_E_MAP_VIEW_OF_FILE: // IsolatedStorageException
                case __HResults.ISS_E_OPEN_FILE_MAPPING: // IsolatedStorageException
                case __HResults.ISS_E_OPEN_STORE_FILE: // IsolatedStorageException
                case __HResults.ISS_E_PATH_LENGTH: // IsolatedStorageException
                case __HResults.ISS_E_SET_FILE_POINTER: // IsolatedStorageException
                case __HResults.ISS_E_STORE_NOT_OPEN: // IsolatedStorageException
                case __HResults.ISS_E_STORE_VERSION: // IsolatedStorageException
                case __HResults.ISS_E_TABLE_ROW_NOT_FOUND: // IsolatedStorageException
                case __HResults.ISS_E_USAGE_WILL_EXCEED_QUOTA: // IsolatedStorageException
                case __HResults.E_FAIL:
                default:
                    break;
            }

            if (exception == null)
            {
                if (createCOMException)
                {
                    exception = new COMException();
                    if (errorCode != __HResults.E_FAIL)
                        shouldDisplayHR = true;
                }
                else
                {
                    exception = new Exception();
                    if (errorCode != __HResults.COR_E_EXCEPTION)
                        shouldDisplayHR = true;
                 }
            }

            bool shouldConstructMessage = false;
            if (hasErrorInfo)
            {
                // If there is a IErrorInfo/IRestrictedErrorInfo, only construct a new error message if
                // the message is not available and do not use the shouldDisplayHR setting
                if (message == null)
                    shouldConstructMessage = true;
            }
            else
            {
                // If there is no IErrorInfo, use the shouldDisplayHR setting from the big switch/case above
                shouldConstructMessage = shouldDisplayHR;
            }

            if (shouldConstructMessage)
            {
                //
                // Append the HR into error message, just in case the app wants to look at the HR in
                // message to determine behavior.  We didn't expose HResult property until v4.5 and
                // GetHRFromException has side effects so probably Message was their only choice.
                // This behavior is probably not exactly the same as in desktop but it is fine to append
                // more message at the end. In any case, having the HR in the error message are helpful
                // to developers.
                // This makes sure:
                // 1. We always have a HR 0xNNNNNNNN in the message
                // 2. Put in a nice "Exception thrown from HRESULT" message if we can
                // 3. Wrap it in () if there is an existing message
                //

                // TODO: Add Symbolic Name into Messaage, convert 0x80020006 to DISP_E_UNKNOWNNAME
                string hrMessage = String.Format("{0} 0x{1}", SR.Excep_FromHResult, errorCode.LowLevelToString());

                message = ExternalInterop.GetMessage(errorCode);

                // Always make sure we have at least the HRESULT part in retail build or when the message
                // is empty.
                if (message == null)
                    message = hrMessage;
                else
                    message = message + " (" + hrMessage + ")";
            }

            if (message != null)
            {
                // Set message explicitly rather than calling constructor because certain ctors would append a
                // prefix to the message and that is not what we want
                InteropExtensions.SetExceptionMessage(exception, message);
            }

            InteropExtensions.SetExceptionErrorCode(exception, errorCode);

            return exception;
        }
コード例 #13
0
        public void Execute_DoesNotWrapThrownExceptionsInAggregateExceptions()
        {
            // Arrange
            var expected = new IndexOutOfRangeException();

            var view = new Mock<IView>();
            view.Setup(v => v.RenderAsync(It.IsAny<ViewContext>()))
                .Throws(expected)
                .Verifiable();

            var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
            viewEngine.Setup(e => e.FindPartialView(It.IsAny<ActionContext>(), It.IsAny<string>()))
                      .Returns(ViewEngineResult.Found("some-view", view.Object))
                      .Verifiable();

            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());

            var result = new ViewViewComponentResult
            {
                ViewEngine = viewEngine.Object,
                ViewName = "some-view",
                ViewData = viewData
            };

            var viewComponentContext = GetViewComponentContext(view.Object, viewData);

            // Act
            var actual = Record.Exception(() => result.Execute(viewComponentContext));

            // Assert
            Assert.Same(expected, actual);
            view.Verify();
        }
コード例 #14
0
        public void Throw_exception_when_Throw_with_specific_exception()
        {
            var exception = new IndexOutOfRangeException("Test");
            int called = 0;
            _something.When(x => x.Echo(Arg.Any<int>())).Do(x => called++);
            _something.When(x => x.Echo(Arg.Any<int>())).Throw(exception);

            Assert.That(called, Is.EqualTo(0), "Should not have been called yet");
            IndexOutOfRangeException thrownException = Assert.Throws<IndexOutOfRangeException>(() => _something.Echo(1234));
            Assert.That(thrownException, Is.EqualTo(exception));
            Assert.That(called, Is.EqualTo(1));
        }
コード例 #15
0
ファイル: KeyState.cs プロジェクト: heinzsack/DEV
		internal void SetInvalidLengthException()
		{
			if (IsFaulted && LastException is IndexOutOfRangeException)
				return;


			LastException = new IndexOutOfRangeException("Der empfangene Schlüssel weist nicht die richtige Länge auf.");
			IsFaulted = true;
			if (KeyInputFailed != null)
				KeyInputFailed(Parent, _lastException);
		}
コード例 #16
0
        public void Execute_DoesNotWrapThrownExceptionsInAggregateExceptions()
        {
            // Arrange
            var expected = new IndexOutOfRangeException();

            var view = new Mock<IView>();
            view.Setup(v => v.RenderAsync(It.IsAny<ViewContext>()))
                .Throws(expected)
                .Verifiable();

            var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
            viewEngine
                .Setup(v => v.GetView(/*executingFilePath*/ null, "some-view", /*isMainPage*/ false))
                .Returns(ViewEngineResult.NotFound("some-view", Enumerable.Empty<string>()))
                .Verifiable();
            viewEngine
                .Setup(v => v.FindView(It.IsAny<ActionContext>(), "Components/Invoke/some-view", /*isMainPage*/ false))
                .Returns(ViewEngineResult.Found("Components/Invoke/some-view", view.Object))
                .Verifiable();

            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());

            var result = new ViewViewComponentResult
            {
                ViewEngine = viewEngine.Object,
                ViewName = "some-view",
                ViewData = viewData,
                TempData = _tempDataDictionary,
            };

            var viewComponentContext = GetViewComponentContext(view.Object, viewData);

            // Act
            var actual = Record.Exception(() => result.Execute(viewComponentContext));

            // Assert
            Assert.Same(expected, actual);
            view.Verify();
        }
コード例 #17
0
ファイル: Stack.cs プロジェクト: dec-k/IN710-keigdl1
 //function to add an item to the top of a stack.
 public void Push(string newString)
 {
     try
     {
         //Put argument string into the stack & increment the iterator
         stack[iterator] = newString;
         iterator++;
     }
     catch (IndexOutOfRangeException)
     {
         //Throws an exception if the stack is already full and provides feedback.
         System.IndexOutOfRangeException exString = new System.IndexOutOfRangeException("You attempted to push to a full stack.");
         throw exString;
     }
 }
コード例 #18
0
    internal static void ThrowSystemException( string message, Type exceptionType, string source, string argument = "" )
    {
      Exception exception;

      if( exceptionType == typeof( ArgumentException ) )
      {
        exception = new ArgumentException( message, argument );
      }
      else if( exceptionType == typeof( ArgumentNullException ) )
      {
        exception = new ArgumentNullException( message );
      }
      else if( exceptionType == typeof( ArgumentOutOfRangeException ) )
      {
        exception = new ArgumentOutOfRangeException( argument, message );
      }
      else if( exceptionType == typeof( IndexOutOfRangeException ) )
      {
        exception = new IndexOutOfRangeException( message );
      }
      else if( exceptionType == typeof( InvalidOperationException ) )
      {
        exception = new InvalidOperationException( message );
      }
      else if( exceptionType == typeof( NotSupportedException ) )
      {
        exception = new NotSupportedException( message );
      }
      else
      {
        exception = new Exception( message );
      }

      exception.Source = source;
      throw exception;
    }
コード例 #19
0
    private void TrigException(int selGridInt)
    {
        switch (selGridInt)
        {
        case 0:
            throwException(new System.Exception("Non-fatal error, an base C# exception"));
            break;

        case 1:
            throwException(new System.SystemException("Fatal error, a system exception"));
            break;

        case 2:
            throwException(new System.ApplicationException("Fatal error, an application exception"));
            break;

        case 3:
            throwException(new System.ArgumentException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 4:
            throwException(new System.FormatException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 5:     // ignore
            break;

        case 6:
            throwException(new System.MemberAccessException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 7:
            throwException(new System.FieldAccessException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 8:
            throwException(new System.MethodAccessException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 9:
            throwException(new System.MissingMemberException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 10:
            throwException(new System.MissingMethodException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 11:
            throwException(new System.MissingFieldException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 12:
            throwException(new System.IndexOutOfRangeException(string.Format("Non-Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 13:
            throwException(new System.ArrayTypeMismatchException(string.Format("Non-Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 14:
            throwException(new System.RankException(string.Format("Non-Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 15:
        case 16:
        case 17:
        case 18:
        case 19:
        case 20:
            try
            {
                throwException(new System.Exception(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            }
            catch (System.Exception e)
            {
                BuglyAgent.ReportException(e, "Caught an exception.");
            }
            break;

        case 21:
            throwException(new System.ArithmeticException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 22:
            throwException(new System.NotFiniteNumberException(string.Format("Fatal error, {0} ", selGridItems[selGridInt])));
            break;

        case 23:
            int i = 0;
            i = 2 / i;
            break;

        case 24:
            throwException(new System.OutOfMemoryException("Fatal error, OOM"));
            break;

        case 25:
            findGameObject();
            break;

        case 26:
            System.Exception excep = null;
            System.IndexOutOfRangeException iore = (System.IndexOutOfRangeException)excep;
            System.Console.Write("" + iore);
            break;

        case 27:
            findGameObjectByTag();
            break;

        case 28:
            DoCrash();
            break;

        case 29:
        default:
            try
            {
                throwException(new System.OutOfMemoryException("Fatal error, out of memory"));
            }
            catch (System.Exception e)
            {
                BuglyAgent.ReportException(e, "Caught Exception");
            }
            break;
        }
    }
コード例 #20
0
ファイル: Enumerator.cs プロジェクト: erisonliang/qizmt
 public static ByteSlice Prepare(ByteSlice data, int offset, int length)
 {
     if (offset < 0 || length < 0 || offset + length > data.length)
     {
         IndexOutOfRangeException ior = new IndexOutOfRangeException("ByteSlice.Prepare(ByteSlice{offset=" + data.offset + ", length=" + data.length + "}, offset=" + offset + ", length=" + length + ")");
         throw new ArgumentOutOfRangeException("Specified argument was out of the range of valid values. Index out of bounds: " + ior.Message, ior); // Preserve the old exception type.
     }
     ByteSlice result;
     result.buf = data.buf;
     result.offset = data.offset + offset;
     result.length = length;
     return result;
 }
コード例 #21
0
ファイル: devCom.cs プロジェクト: tbergmueller/tblcsharp
        /// <summary>
        /// Liefert ein Byte an einer bestimmten Position im Buffer
        /// </summary>
        /// <param name="vPos"></param>
        /// <exception cref="IndexOutOfRangeException">Index out of range - Exception wenn übergebene Position außerhalb des Buffers liegt</exception>
        /// <returns>Byte an angegebener Position</returns>
        /// <remarks>Threadsicherer Aufruf. Wollen andere Threads auf den Buffer zugreifen, müssen sie warten.</remarks>
        public byte ReadByte(int vPos)
        {
            accessControl.WaitOne(); // Sperren des Threads...
            if(vPos >= dptr)
            {
                accessControl.Release(); // Release, andere können wider zugreifen, es wird nichts gemacht
                IndexOutOfRangeException ex = new IndexOutOfRangeException("@ Function ThreadSafeReceiveBuffer.ReadByte(int): Übergebene Position liegt außerhalb des Buffers. Aktuelle Buffergröße: " + dptr.ToString() + "Bytes");
                throw ex;
            }

            accessControl.Release(); // Release, andere können wieder zugreifen
            return(buffer[vPos]);
        }
コード例 #22
0
 internal static IndexOutOfRangeException IndexOutOfRange(string error)
 {
     IndexOutOfRangeException e = new IndexOutOfRangeException(error);
     TraceExceptionAsReturnValue(e);
     return e;
 }
コード例 #23
0
 internal static IndexOutOfRangeException IndexOutOfRange(int value)
 {
     IndexOutOfRangeException e = new IndexOutOfRangeException(value.ToString(CultureInfo.InvariantCulture));
     TraceExceptionAsReturnValue(e);
     return e;
 }
コード例 #24
0
ファイル: Stack.cs プロジェクト: dec-k/IN710-keigdl1
        //Pops off the most recently item added to the stack.
        public String Pop()
        {
            try {
                //create a string, used to show user output.
                string mostRecentItem = stack[iterator - 1];

                //Clear the currently watched part of the stack and reduce the iterator.
                stack[--iterator] = null;
                return mostRecentItem;
            }
            catch (IndexOutOfRangeException)
            {
                System.IndexOutOfRangeException exString = new System.IndexOutOfRangeException("You attempted to pop from an empty stack.");
                throw exString;
            }
        }
コード例 #25
0
 public InvalidMapException(string message, IndexOutOfRangeException outOfRangeException)
     : base(message, outOfRangeException)
 {
 }