Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / SafeEventLogWriteHandle.cs / 1305376 / SafeEventLogWriteHandle.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Diagnostics { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; using System.Runtime; [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] SafeEventLogWriteHandle() : base(true) { } [ResourceConsumption(ResourceScope.Machine)] [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] internal static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = NativeMethods.RegisterEventSource(uncServerName, sourceName); int error = Marshal.GetLastWin32Error(); if (retval.IsInvalid) { Debug.Print("SafeEventLogWriteHandle::RegisterEventSource[" + uncServerName + ", " + sourceName + "] Failed. Last Error: " + error.ToString(CultureInfo.InvariantCulture)); } return retval; } [DllImport("advapi32", SetLastError = true)] [ResourceExposure(ResourceScope.None)] private static extern bool DeregisterEventSource(IntPtr hEventLog); #pragma warning disable 56523 [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] override protected bool ReleaseHandle() { return DeregisterEventSource(this.handle); } #pragma warning restore 56523 } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OutputCacheProfile.cs
- KeyProperty.cs
- WebPartZoneBase.cs
- OutputScopeManager.cs
- BufferedGraphics.cs
- RectAnimationUsingKeyFrames.cs
- CounterNameConverter.cs
- EventLog.cs
- SystemIPInterfaceStatistics.cs
- KeyPressEvent.cs
- SatelliteContractVersionAttribute.cs
- ListViewGroupConverter.cs
- ClientTargetSection.cs
- EncodingInfo.cs
- StylusPointCollection.cs
- HttpRawResponse.cs
- XmlElementCollection.cs
- OperationContext.cs
- CheckBoxAutomationPeer.cs
- HtmlGenericControl.cs
- SspiWrapper.cs
- CommandHelper.cs
- RelationshipConstraintValidator.cs
- XmlCodeExporter.cs
- SimpleWorkerRequest.cs
- TransactionFormatter.cs
- ImageDrawing.cs
- WebServiceResponseDesigner.cs
- MessageEncodingBindingElementImporter.cs
- ExclusiveHandle.cs
- UnsafeNativeMethods.cs
- ButtonBaseAdapter.cs
- ElementsClipboardData.cs
- RecognizerStateChangedEventArgs.cs
- ListParaClient.cs
- SafeFileMappingHandle.cs
- Base64Stream.cs
- MobilePage.cs
- ConfigurationConverterBase.cs
- DbCommandTree.cs
- AsymmetricKeyExchangeDeformatter.cs
- ExtensionFile.cs
- Contracts.cs
- DoubleAnimationUsingKeyFrames.cs
- DispatcherExceptionFilterEventArgs.cs
- objectresult_tresulttype.cs
- SerializationInfo.cs
- BackoffTimeoutHelper.cs
- UnsafeNativeMethods.cs
- PropertyGridCommands.cs
- PointCollection.cs
- CodeLinePragma.cs
- ServiceBuildProvider.cs
- WindowsFont.cs
- AdornerPresentationContext.cs
- DocumentViewerHelper.cs
- CategoryNameCollection.cs
- ProfileSection.cs
- NameScopePropertyAttribute.cs
- BaseResourcesBuildProvider.cs
- PersonalizationStateQuery.cs
- ReadOnlyDataSource.cs
- SyndicationDeserializer.cs
- DesignerView.xaml.cs
- XPathCompiler.cs
- DataGridViewColumnCollection.cs
- DesignerAttribute.cs
- input.cs
- BufferedGraphicsManager.cs
- ForeignKeyConstraint.cs
- TextStore.cs
- CustomTypeDescriptor.cs
- CodeMethodReturnStatement.cs
- CodeDelegateCreateExpression.cs
- SizeLimitedCache.cs
- StateWorkerRequest.cs
- LinkedList.cs
- ToolstripProfessionalRenderer.cs
- SectionVisual.cs
- Converter.cs
- JoinSymbol.cs
- JulianCalendar.cs
- PerformanceCounterPermissionEntry.cs
- ControlDesignerState.cs
- SecurityTokenParameters.cs
- Misc.cs
- TemplatedMailWebEventProvider.cs
- RNGCryptoServiceProvider.cs
- TimeoutValidationAttribute.cs
- DocumentGrid.cs
- Matrix3DConverter.cs
- TransformCryptoHandle.cs
- SQLGuid.cs
- AvTraceDetails.cs
- DependencyPropertyKind.cs
- XmlProcessingInstruction.cs
- ContainerSelectorGlyph.cs
- HotSpotCollection.cs
- CellIdBoolean.cs
- ProfileModule.cs