Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / AssertUtility.cs / 1 / AssertUtility.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- // This class needs to function even if it was built retail. That is, a debug caller calling against a retail // SMDiagnostics should still have asserts fire. To achieve that, we need to define DEBUG here. // We do not do the registry override in retail SMDiagnostics because that would require shipping a test hook. We // do not generally ship test hooks today. #if DEBUG #define DEBUG_FOR_REALS #else #define DEBUG #endif namespace System.ServiceModel.Diagnostics { using System; using System.Diagnostics; using System.Runtime.CompilerServices; using Microsoft.Win32; static class AssertUtility { #if DEBUG_FOR_REALS const string WinFXRegistryKey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP"; const string WcfRegistryKey = AssertUtility.WinFXRegistryKey + @"\v3.0\Setup\Windows Communication Foundation"; const string AssertsFailFastName = "AssertsFailFast"; #endif [Obsolete("For SMDiagnostics.dll use only. Call DiagnosticUtility.DebugAssert instead")] internal static void DebugAssertCore(string message) { try { #if DEBUG_FOR_REALS string debugMessage = "WCF Assert fired! --> " + message + "\r\n"; if (Debugger.IsAttached) { Debugger.Log(0, Debugger.DefaultCategory, debugMessage); Debugger.Break(); } if (NativeMethods.IsDebuggerPresent()) { NativeMethods.OutputDebugString(debugMessage); NativeMethods.DebugBreak(); } // This can be switched to just FailFast (e.g. for the stress lab). RegistryKey key = Registry.LocalMachine.OpenSubKey(AssertUtility.WcfRegistryKey); if (key != null) { object value; using (key) { value = key.GetValue(AssertUtility.AssertsFailFastName); } if (value != null && typeof(int).IsAssignableFrom(value.GetType()) && ((int) value) != 0) { try { if (ExceptionUtility.mainInstance != null) { #pragma warning disable 618 ExceptionUtility.mainInstance.TraceFailFast(message); } else { ExceptionUtility.TraceFailFast(message, new EventLogger("System.ServiceModel", null)); } #pragma warning restore 618 } finally { Environment.FailFast(message); } } } } catch (Exception exception) { message = string.Concat("Exception during assert! [", exception.GetType().Name, ": ", exception.Message, "] --> ", message); throw; #endif } finally { Debug.Assert(false, message); } } // For use within SMDiagnostics. [Conditional("DEBUG")] [Obsolete("For SMDiagnostics.dll use only. Call DiagnosticUtility.DebugAssert instead")] internal static void DebugAssert(bool condition, string message) { if (!condition) { DebugAssert(message); } } [MethodImpl(MethodImplOptions.NoInlining)] [Conditional("DEBUG")] [Obsolete("For SMDiagnostics.dll use only. Call DiagnosticUtility.DebugAssert instead")] internal static void DebugAssert(string message) { DebugAssertCore(message); } } } // 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
- MouseGestureValueSerializer.cs
- CatalogPartCollection.cs
- SqlDataReaderSmi.cs
- XmlNavigatorStack.cs
- TypeCacheManager.cs
- DesignOnlyAttribute.cs
- DataGridViewHitTestInfo.cs
- WebPartConnectionsConnectVerb.cs
- Helpers.cs
- Transform.cs
- WebPartTransformerAttribute.cs
- PrePrepareMethodAttribute.cs
- Icon.cs
- DivideByZeroException.cs
- ErasingStroke.cs
- UidPropertyAttribute.cs
- Renderer.cs
- ResourceLoader.cs
- ReliableReplySessionChannel.cs
- TextEditorTyping.cs
- UserInitiatedRoutedEventPermission.cs
- WindowsSolidBrush.cs
- RegisterInfo.cs
- CompositionTarget.cs
- RequestQueue.cs
- ContentPlaceHolder.cs
- RSAPKCS1KeyExchangeFormatter.cs
- MetadataException.cs
- Path.cs
- XmlWellformedWriter.cs
- TimelineClockCollection.cs
- DesignerExtenders.cs
- FontSourceCollection.cs
- String.cs
- LocationSectionRecord.cs
- PropertyMetadata.cs
- EncoderParameters.cs
- MarkupCompilePass1.cs
- Psha1DerivedKeyGenerator.cs
- FontNamesConverter.cs
- SerializeAbsoluteContext.cs
- ConfigXmlAttribute.cs
- GridLengthConverter.cs
- StrongNameHelpers.cs
- BrowserDefinition.cs
- Input.cs
- XmlAttributes.cs
- XmlNamespaceDeclarationsAttribute.cs
- FilterInvalidBodyAccessException.cs
- XPathChildIterator.cs
- XmlSequenceWriter.cs
- TreeViewItem.cs
- EntityDataSourceSelectingEventArgs.cs
- Utils.cs
- ToolboxCategoryItems.cs
- MD5.cs
- FormClosingEvent.cs
- CollectionViewProxy.cs
- ObjectStateFormatter.cs
- MultipleFilterMatchesException.cs
- SubclassTypeValidator.cs
- RandomDelaySendsAsyncResult.cs
- ByteStreamGeometryContext.cs
- TdsParserSessionPool.cs
- GlyphTypeface.cs
- HyperLinkStyle.cs
- _NestedSingleAsyncResult.cs
- ButtonFieldBase.cs
- PolyLineSegmentFigureLogic.cs
- XPathChildIterator.cs
- ReachIDocumentPaginatorSerializer.cs
- XmlSyndicationContent.cs
- Vars.cs
- NumberSubstitution.cs
- SystemIPv6InterfaceProperties.cs
- QilSortKey.cs
- __ComObject.cs
- MSAAEventDispatcher.cs
- ZipArchive.cs
- MinMaxParagraphWidth.cs
- XamlSerializerUtil.cs
- FloatUtil.cs
- LabelAutomationPeer.cs
- WindowsTooltip.cs
- DataGridPagerStyle.cs
- Transactions.cs
- VersionConverter.cs
- DesignerPerfEventProvider.cs
- MissingSatelliteAssemblyException.cs
- EntityDataSourceWrapperCollection.cs
- Privilege.cs
- ParallelDesigner.xaml.cs
- PerspectiveCamera.cs
- TaskbarItemInfo.cs
- ManagementObjectSearcher.cs
- VisualStateManager.cs
- ModifierKeysConverter.cs
- MultiViewDesigner.cs
- NamespaceList.cs
- Function.cs