Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / CriticalExceptions.cs / 1305600 / CriticalExceptions.cs
using System;
#if PBTCOMPILER
namespace MS.Internal.Markup
#elif SYSTEM_XAML
namespace System.Xaml
#else
using MS.Internal.WindowsBase; // FriendAccessAllowed
namespace MS.Internal
#endif
{
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static class CriticalExceptions
{
// these are all the exceptions considered critical by PreSharp
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static bool IsCriticalException(Exception ex)
{
ex = Unwrap(ex);
return ex is NullReferenceException ||
ex is StackOverflowException ||
ex is OutOfMemoryException ||
ex is System.Threading.ThreadAbortException ||
ex is System.Runtime.InteropServices.SEHException ||
ex is System.Security.SecurityException;
}
// these are exceptions that we should treat as critical when they
// arise during callbacks into application code
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
internal static bool IsCriticalApplicationException(Exception ex)
{
ex = Unwrap(ex);
return ex is StackOverflowException ||
ex is OutOfMemoryException ||
ex is System.Threading.ThreadAbortException ||
ex is System.Security.SecurityException;
}
#endif
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static Exception Unwrap(Exception ex)
{
// for certain types of exceptions, we care more about the inner
// exception
while (ex.InnerException != null &&
( ex is System.Reflection.TargetInvocationException
))
{
ex = ex.InnerException;
}
return ex;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
#if PBTCOMPILER
namespace MS.Internal.Markup
#elif SYSTEM_XAML
namespace System.Xaml
#else
using MS.Internal.WindowsBase; // FriendAccessAllowed
namespace MS.Internal
#endif
{
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static class CriticalExceptions
{
// these are all the exceptions considered critical by PreSharp
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static bool IsCriticalException(Exception ex)
{
ex = Unwrap(ex);
return ex is NullReferenceException ||
ex is StackOverflowException ||
ex is OutOfMemoryException ||
ex is System.Threading.ThreadAbortException ||
ex is System.Runtime.InteropServices.SEHException ||
ex is System.Security.SecurityException;
}
// these are exceptions that we should treat as critical when they
// arise during callbacks into application code
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
internal static bool IsCriticalApplicationException(Exception ex)
{
ex = Unwrap(ex);
return ex is StackOverflowException ||
ex is OutOfMemoryException ||
ex is System.Threading.ThreadAbortException ||
ex is System.Security.SecurityException;
}
#endif
#if !PBTCOMPILER && !SYSTEM_XAML
[FriendAccessAllowed]
#endif
internal static Exception Unwrap(Exception ex)
{
// for certain types of exceptions, we care more about the inner
// exception
while (ex.InnerException != null &&
( ex is System.Reflection.TargetInvocationException
))
{
ex = ex.InnerException;
}
return ex;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RowToFieldTransformer.cs
- SerializationSectionGroup.cs
- Stack.cs
- LambdaCompiler.Statements.cs
- WebPartDisplayModeCollection.cs
- Int16Animation.cs
- CultureInfo.cs
- SiteMapSection.cs
- PostBackOptions.cs
- UniqueConstraint.cs
- Matrix3D.cs
- DataGridViewColumnConverter.cs
- _NegotiateClient.cs
- DependencyObjectProvider.cs
- BitmapEffectInputConnector.cs
- Types.cs
- HtmlElement.cs
- BatchStream.cs
- LogicalCallContext.cs
- MarkupObject.cs
- StringConcat.cs
- GridView.cs
- ComPlusTypeValidator.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- HttpPostedFile.cs
- RewritingValidator.cs
- WebSysDisplayNameAttribute.cs
- VerticalAlignConverter.cs
- MetafileHeader.cs
- PropertyChangedEventManager.cs
- ObjectDataSourceMethodEventArgs.cs
- PenLineJoinValidation.cs
- PageContentCollection.cs
- PolicyChain.cs
- OdbcCommand.cs
- FileDataSourceCache.cs
- ShapeTypeface.cs
- OperationInvokerBehavior.cs
- Metadata.cs
- ListViewHitTestInfo.cs
- JsonEncodingStreamWrapper.cs
- SpecialFolderEnumConverter.cs
- XPathAxisIterator.cs
- KnownTypesHelper.cs
- ThicknessAnimation.cs
- SqlErrorCollection.cs
- KeyEventArgs.cs
- TableMethodGenerator.cs
- SuppressIldasmAttribute.cs
- MissingMemberException.cs
- WorkflowInstanceExtensionManager.cs
- PenLineJoinValidation.cs
- XmlILOptimizerVisitor.cs
- ShaderEffect.cs
- CounterCreationDataConverter.cs
- SizeConverter.cs
- Base64Stream.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- WhitespaceSignificantCollectionAttribute.cs
- NativeWindow.cs
- ToolStripItemCollection.cs
- ThrowOnMultipleAssignment.cs
- EdmItemCollection.cs
- FixedSOMPage.cs
- _LoggingObject.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- EventHandlersDesigner.cs
- SeekStoryboard.cs
- Literal.cs
- EventListener.cs
- PathFigureCollection.cs
- CodeGotoStatement.cs
- PolicyException.cs
- EventLog.cs
- SslStream.cs
- XPathAxisIterator.cs
- ExpressionBuilderContext.cs
- Atom10FormatterFactory.cs
- Rotation3D.cs
- WorkflowServiceAttributes.cs
- TrustManager.cs
- UdpSocket.cs
- CodeCatchClauseCollection.cs
- BamlRecordHelper.cs
- QilTernary.cs
- RowBinding.cs
- FileDialog.cs
- OrderedDictionary.cs
- ConfigurationManagerInternalFactory.cs
- SocketPermission.cs
- UnsafeNativeMethodsMilCoreApi.cs
- DataGridViewDataErrorEventArgs.cs
- LayoutExceptionEventArgs.cs
- TransformProviderWrapper.cs
- RunWorkerCompletedEventArgs.cs
- SyndicationLink.cs
- InstallHelper.cs
- ListViewInsertedEventArgs.cs
- PLINQETWProvider.cs
- ReflectionServiceProvider.cs