Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / ExceptionHandler.cs / 1 / ExceptionHandler.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System.Runtime.ConstrainedExecution; using System.Diagnostics; using System.ServiceModel; using System.ServiceModel.Diagnostics; using System.Security.Permissions; using System.Security; public abstract class ExceptionHandler { static readonly ExceptionHandler alwaysHandle = new AlwaysHandleExceptionHandler(); ////// Critical - this delegate is called from within a ConstrainedExecutionRegion /// must not be settable from PT code /// [SecurityCritical] static ExceptionHandler asynchronousThreadExceptionHandler; static ExceptionHandler transportExceptionHandler = alwaysHandle; public static ExceptionHandler AlwaysHandle { get { return alwaysHandle; } } public static ExceptionHandler AsynchronousThreadExceptionHandler { ////// Critical - access critical field /// Safe - ok for get-only access /// [SecurityCritical, SecurityTreatAsSafe] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] get { return asynchronousThreadExceptionHandler; } ////// Critical - sets a critical field /// Safe - protected with LinkDemand /// [SecurityCritical, SecurityTreatAsSafe] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] set { asynchronousThreadExceptionHandler = value; } } public static ExceptionHandler TransportExceptionHandler { get { return transportExceptionHandler; } set { transportExceptionHandler = value; } } // Returns true if the exception has been handled. If it returns false or // throws a different exception, the original exception will be rethrown. public abstract bool HandleException(Exception exception); class AlwaysHandleExceptionHandler : ExceptionHandler { ////// RequiresReview - this function can be called from within a CER, must not call into PT code /// [SecurityRequiresReview] public override bool HandleException(Exception exception) { return true; } } internal static bool HandleTransportExceptionHelper(Exception exception) { if (exception == null) { DiagnosticUtility.DebugAssert("Null exception passed to HandleTransportExceptionHelper."); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } ExceptionHandler handler = TransportExceptionHandler; if (handler == null) { return false; } try { if (!handler.HandleException(exception)) { return false; } } catch (Exception thrownException) { if (DiagnosticUtility.IsFatal(thrownException)) { throw; } if (DiagnosticUtility.ShouldTraceError) { DiagnosticUtility.ExceptionUtility.TraceHandledException(thrownException, TraceEventType.Error); } return false; } if (DiagnosticUtility.ShouldTraceError) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error); } return true; } } } // 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
- NavigationProperty.cs
- EndpointAddressProcessor.cs
- StatusBar.cs
- WebColorConverter.cs
- CodeTypeDeclarationCollection.cs
- GridViewUpdatedEventArgs.cs
- ProjectionPath.cs
- EntityObject.cs
- CardSpaceShim.cs
- ImageSource.cs
- odbcmetadatafactory.cs
- UrlAuthorizationModule.cs
- ControlIdConverter.cs
- TextCharacters.cs
- errorpatternmatcher.cs
- TypeUtil.cs
- GeometryConverter.cs
- DataShape.cs
- base64Transforms.cs
- SwitchLevelAttribute.cs
- ProbeDuplexCD1AsyncResult.cs
- SimpleTypesSurrogate.cs
- ChineseLunisolarCalendar.cs
- SequenceRange.cs
- Animatable.cs
- UrlPath.cs
- ArrayTypeMismatchException.cs
- EventLogHandle.cs
- ExpandableObjectConverter.cs
- HideDisabledControlAdapter.cs
- SystemWebCachingSectionGroup.cs
- Model3DGroup.cs
- CaretElement.cs
- MimeObjectFactory.cs
- WebPartConnectionsEventArgs.cs
- PromptEventArgs.cs
- DefaultValueTypeConverter.cs
- DecimalConstantAttribute.cs
- TreeViewItem.cs
- DBSqlParser.cs
- EventLogPermission.cs
- SafeCancelMibChangeNotify.cs
- ReadingWritingEntityEventArgs.cs
- BitmapSource.cs
- MsmqIntegrationSecurity.cs
- XmlUtf8RawTextWriter.cs
- ConnectionStringsSection.cs
- TypeInformation.cs
- GuidConverter.cs
- HtmlInputButton.cs
- LockCookie.cs
- RowSpanVector.cs
- AddingNewEventArgs.cs
- ConfigurationSectionGroup.cs
- MessageLogger.cs
- InfiniteIntConverter.cs
- SqlTypesSchemaImporter.cs
- DashStyle.cs
- GenericRootAutomationPeer.cs
- FormViewAutoFormat.cs
- SinglePageViewer.cs
- InternalEnumValidator.cs
- InstanceDescriptor.cs
- TimeSpanValidator.cs
- CleanUpVirtualizedItemEventArgs.cs
- BitmapEffect.cs
- LayoutInformation.cs
- ListSortDescriptionCollection.cs
- PageFunction.cs
- CanonicalFontFamilyReference.cs
- GroupStyle.cs
- ImageCollectionCodeDomSerializer.cs
- ListViewUpdatedEventArgs.cs
- XmlSchemaGroup.cs
- CompilationUnit.cs
- KeyInstance.cs
- XamlSerializationHelper.cs
- SchemaElement.cs
- AuthStoreRoleProvider.cs
- GlyphElement.cs
- BaseDataBoundControl.cs
- PropertyGroupDescription.cs
- IndexedDataBuffer.cs
- XmlEncodedRawTextWriter.cs
- XmlUtil.cs
- BrowserCapabilitiesFactoryBase.cs
- SqlCharStream.cs
- ProgressBar.cs
- ScriptDescriptor.cs
- EmptyImpersonationContext.cs
- PresentationSource.cs
- CompositeActivityTypeDescriptor.cs
- DefaultPropertyAttribute.cs
- StringStorage.cs
- AdornerPresentationContext.cs
- JsonWriterDelegator.cs
- followingquery.cs
- TextCollapsingProperties.cs
- HttpWebResponse.cs
- OutputBuffer.cs