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
- Exceptions.cs
- BoolExpr.cs
- GrammarBuilder.cs
- ContentControl.cs
- TimelineCollection.cs
- SystemParameters.cs
- WebPartCollection.cs
- InstancePersistenceCommand.cs
- BindingMAnagerBase.cs
- TypeExtensionConverter.cs
- TextProperties.cs
- CodeExporter.cs
- HotCommands.cs
- DerivedKeySecurityToken.cs
- ObjectView.cs
- COM2PictureConverter.cs
- HtmlEncodedRawTextWriter.cs
- XmlSchemaSimpleContent.cs
- ResourceReferenceExpression.cs
- EntityViewContainer.cs
- RuleSetReference.cs
- TextSelectionProcessor.cs
- ProjectionPathBuilder.cs
- CustomTypeDescriptor.cs
- MenuItem.cs
- SectionInput.cs
- ViewLoader.cs
- RelatedImageListAttribute.cs
- IriParsingElement.cs
- Page.cs
- CroppedBitmap.cs
- Documentation.cs
- RecipientIdentity.cs
- XmlStreamNodeWriter.cs
- SelfIssuedAuthAsymmetricKey.cs
- DataGridViewElement.cs
- URLIdentityPermission.cs
- AxWrapperGen.cs
- ComboBox.cs
- StrokeCollectionConverter.cs
- DeploymentSectionCache.cs
- UnmanagedBitmapWrapper.cs
- MenuItemBinding.cs
- RegexInterpreter.cs
- DeploymentSection.cs
- LinkLabel.cs
- ApplicationHost.cs
- SelectionItemProviderWrapper.cs
- UndirectedGraph.cs
- ReachFixedPageSerializer.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- ComplexType.cs
- ApplicationBuildProvider.cs
- WebPartVerbsEventArgs.cs
- XPathChildIterator.cs
- DataBindingList.cs
- CookieProtection.cs
- SemaphoreSecurity.cs
- CodeDirectiveCollection.cs
- TreeNode.cs
- RegexRunner.cs
- StringArrayConverter.cs
- SectionInput.cs
- SetStateEventArgs.cs
- SqlUdtInfo.cs
- RadialGradientBrush.cs
- UriTemplateLiteralQueryValue.cs
- FlowDocument.cs
- MessageHeaderDescription.cs
- MetadataUtilsSmi.cs
- ReceiveSecurityHeader.cs
- LocalizedNameDescriptionPair.cs
- VersionedStream.cs
- HtmlForm.cs
- PageClientProxyGenerator.cs
- C14NUtil.cs
- ManagementScope.cs
- UnionExpr.cs
- OLEDB_Util.cs
- SqlGatherProducedAliases.cs
- XmlHelper.cs
- CompileLiteralTextParser.cs
- ImageFormat.cs
- ReflectionHelper.cs
- InvalidDataException.cs
- SecurityContextCookieSerializer.cs
- ToolStripRenderer.cs
- GCHandleCookieTable.cs
- PolicyException.cs
- KeyFrames.cs
- BooleanFunctions.cs
- UInt16Storage.cs
- OLEDB_Enum.cs
- WasHttpModulesInstallComponent.cs
- ActivityMarkupSerializer.cs
- Atom10FormatterFactory.cs
- SafeNativeMethods.cs
- ObjectDataSourceView.cs
- wgx_commands.cs
- HtmlInputSubmit.cs