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
- SimpleMailWebEventProvider.cs
- InfoCardBaseException.cs
- httpstaticobjectscollection.cs
- PropertyPath.cs
- Span.cs
- CheckBoxStandardAdapter.cs
- WebPartCollection.cs
- PixelShader.cs
- QuarticEase.cs
- ButtonStandardAdapter.cs
- AddingNewEventArgs.cs
- SmiXetterAccessMap.cs
- SqlBulkCopyColumnMappingCollection.cs
- TreeViewCancelEvent.cs
- TextElementCollection.cs
- AsymmetricKeyExchangeFormatter.cs
- StrokeCollection2.cs
- MouseGesture.cs
- DataSourceExpression.cs
- ProbeMatchesApril2005.cs
- LiteralTextParser.cs
- ObjectQueryProvider.cs
- ListMarkerSourceInfo.cs
- FontDialog.cs
- SymLanguageVendor.cs
- SharedPerformanceCounter.cs
- QilGenerator.cs
- PackageDigitalSignature.cs
- wgx_render.cs
- OdbcCommand.cs
- ParallelEnumerableWrapper.cs
- HashSet.cs
- BufferedGraphicsManager.cs
- MarkupWriter.cs
- Argument.cs
- RawAppCommandInputReport.cs
- Maps.cs
- FrameworkContentElement.cs
- WindowsEditBox.cs
- SafeFileMappingHandle.cs
- BitmapSourceSafeMILHandle.cs
- storagemappingitemcollection.viewdictionary.cs
- Marshal.cs
- ProjectionCamera.cs
- Validator.cs
- XPathQilFactory.cs
- SqlSupersetValidator.cs
- ControlIdConverter.cs
- ReaderContextStackData.cs
- ExecutionContext.cs
- EdmItemCollection.cs
- CharUnicodeInfo.cs
- _CookieModule.cs
- Screen.cs
- DefinitionUpdate.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- ButtonField.cs
- SuppressIldasmAttribute.cs
- Rotation3DAnimationBase.cs
- DataRecordInfo.cs
- SafeCryptoHandles.cs
- DataColumnPropertyDescriptor.cs
- XmlSchemaElement.cs
- BezierSegment.cs
- ThrowOnMultipleAssignment.cs
- BStrWrapper.cs
- StandardOleMarshalObject.cs
- ZipIOLocalFileDataDescriptor.cs
- NavigateEvent.cs
- HttpWebResponse.cs
- KnownTypeAttribute.cs
- HtmlTableCellCollection.cs
- ScriptHandlerFactory.cs
- NeutralResourcesLanguageAttribute.cs
- XsdBuildProvider.cs
- HtmlTableRow.cs
- DataSvcMapFileSerializer.cs
- StatusBar.cs
- StorageFunctionMapping.cs
- ApplicationId.cs
- SqlWebEventProvider.cs
- DbBuffer.cs
- Viewport3DVisual.cs
- ExpressionBuilder.cs
- ListViewSelectEventArgs.cs
- LoadWorkflowByInstanceKeyCommand.cs
- RoutedCommand.cs
- ListView.cs
- UrlUtility.cs
- ArgumentDesigner.xaml.cs
- RuntimeHandles.cs
- XmlSchemaSimpleTypeList.cs
- Debug.cs
- MailWebEventProvider.cs
- LocalizableResourceBuilder.cs
- Region.cs
- CounterCreationData.cs
- XmlWrappingReader.cs
- XmlNode.cs
- FileDetails.cs