Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / EventLogException.cs / 1305376 / EventLogException.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: EventLogException
**
** Purpose:
** This public class describes an exception thrown from Event
** Log related classes.
**
============================================================*/
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace System.Diagnostics.Eventing.Reader {
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogException : Exception, ISerializable {
internal static void Throw(int errorCode) {
switch (errorCode) {
case 2:
case 3:
case 15007:
case 15027:
case 15028:
case 15002:
throw new EventLogNotFoundException(errorCode);
case 13:
case 15005:
throw new EventLogInvalidDataException(errorCode);
case 1818: // RPC_S_CALL_CANCELED is converted to ERROR_CANCELLED
case 1223:
throw new OperationCanceledException();
case 15037:
throw new EventLogProviderDisabledException(errorCode);
case 5:
throw new UnauthorizedAccessException();
case 15011:
case 15012:
throw new EventLogReadingException(errorCode);
default: throw new EventLogException(errorCode);
}
}
public EventLogException() { }
public EventLogException(string message) : base(message) { }
public EventLogException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
protected EventLogException(int errorCode) { this.errorCode = errorCode; }
// SecurityCritical due to inherited link demand for GetObjectData.
[System.Security.SecurityCritical,SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info == null)
throw new ArgumentNullException("info");
info.AddValue("errorCode", errorCode);
base.GetObjectData(info, context);
}
public override string Message {
// marked as SecurityCritical because it uses Win32Exception.
// marked as TreatAsSafe because it performs Demand.
[System.Security.SecurityCritical]
get {
EventLogPermissionHolder.GetEventLogPermission().Demand();
Win32Exception win32Exception = new Win32Exception(errorCode);
return win32Exception.Message;
}
}
private int errorCode;
}
///
/// The object requested by the operation is not found.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogNotFoundException : EventLogException {
public EventLogNotFoundException() { }
public EventLogNotFoundException(string message) : base(message) { }
public EventLogNotFoundException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogNotFoundException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogNotFoundException(int errorCode) : base(errorCode) { }
}
///
/// The state of the reader cursor has become invalid, most likely due to the fact
/// that the log has been cleared. User needs to obtain a new reader object if
/// they wish to continue navigating result set.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogReadingException : EventLogException {
public EventLogReadingException() { }
public EventLogReadingException(string message) : base(message) { }
public EventLogReadingException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogReadingException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogReadingException(int errorCode) : base(errorCode) { }
}
///
/// Provider has been uninstalled while ProviderMetadata operations are being performed.
/// Obtain a new ProviderMetadata object, when provider is reinstalled, to continue navigating
/// provider's metadata.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogProviderDisabledException : EventLogException {
public EventLogProviderDisabledException() { }
public EventLogProviderDisabledException(string message) : base(message) { }
public EventLogProviderDisabledException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogProviderDisabledException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogProviderDisabledException(int errorCode) : base(errorCode) { }
}
///
/// Data obtained from the eventlog service, for the current operation, is invalid .
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogInvalidDataException : EventLogException {
public EventLogInvalidDataException() { }
public EventLogInvalidDataException(string message) : base(message) { }
public EventLogInvalidDataException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogInvalidDataException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogInvalidDataException(int errorCode) : base(errorCode) { }
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: EventLogException
**
** Purpose:
** This public class describes an exception thrown from Event
** Log related classes.
**
============================================================*/
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace System.Diagnostics.Eventing.Reader {
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogException : Exception, ISerializable {
internal static void Throw(int errorCode) {
switch (errorCode) {
case 2:
case 3:
case 15007:
case 15027:
case 15028:
case 15002:
throw new EventLogNotFoundException(errorCode);
case 13:
case 15005:
throw new EventLogInvalidDataException(errorCode);
case 1818: // RPC_S_CALL_CANCELED is converted to ERROR_CANCELLED
case 1223:
throw new OperationCanceledException();
case 15037:
throw new EventLogProviderDisabledException(errorCode);
case 5:
throw new UnauthorizedAccessException();
case 15011:
case 15012:
throw new EventLogReadingException(errorCode);
default: throw new EventLogException(errorCode);
}
}
public EventLogException() { }
public EventLogException(string message) : base(message) { }
public EventLogException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
protected EventLogException(int errorCode) { this.errorCode = errorCode; }
// SecurityCritical due to inherited link demand for GetObjectData.
[System.Security.SecurityCritical,SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info == null)
throw new ArgumentNullException("info");
info.AddValue("errorCode", errorCode);
base.GetObjectData(info, context);
}
public override string Message {
// marked as SecurityCritical because it uses Win32Exception.
// marked as TreatAsSafe because it performs Demand.
[System.Security.SecurityCritical]
get {
EventLogPermissionHolder.GetEventLogPermission().Demand();
Win32Exception win32Exception = new Win32Exception(errorCode);
return win32Exception.Message;
}
}
private int errorCode;
}
///
/// The object requested by the operation is not found.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogNotFoundException : EventLogException {
public EventLogNotFoundException() { }
public EventLogNotFoundException(string message) : base(message) { }
public EventLogNotFoundException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogNotFoundException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogNotFoundException(int errorCode) : base(errorCode) { }
}
///
/// The state of the reader cursor has become invalid, most likely due to the fact
/// that the log has been cleared. User needs to obtain a new reader object if
/// they wish to continue navigating result set.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogReadingException : EventLogException {
public EventLogReadingException() { }
public EventLogReadingException(string message) : base(message) { }
public EventLogReadingException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogReadingException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogReadingException(int errorCode) : base(errorCode) { }
}
///
/// Provider has been uninstalled while ProviderMetadata operations are being performed.
/// Obtain a new ProviderMetadata object, when provider is reinstalled, to continue navigating
/// provider's metadata.
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogProviderDisabledException : EventLogException {
public EventLogProviderDisabledException() { }
public EventLogProviderDisabledException(string message) : base(message) { }
public EventLogProviderDisabledException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogProviderDisabledException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogProviderDisabledException(int errorCode) : base(errorCode) { }
}
///
/// Data obtained from the eventlog service, for the current operation, is invalid .
///
[Serializable]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class EventLogInvalidDataException : EventLogException {
public EventLogInvalidDataException() { }
public EventLogInvalidDataException(string message) : base(message) { }
public EventLogInvalidDataException(string message, Exception innerException) : base(message, innerException) { }
protected EventLogInvalidDataException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { }
internal EventLogInvalidDataException(int errorCode) : base(errorCode) { }
}
}
// 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
- StrokeNodeData.cs
- AssemblyBuilder.cs
- BindToObject.cs
- XmlSchemaAny.cs
- HtmlTableCellCollection.cs
- NativeMethodsOther.cs
- ListViewGroup.cs
- SqlXmlStorage.cs
- GroupBox.cs
- CodeAttributeDeclaration.cs
- DelayedRegex.cs
- RecognitionEventArgs.cs
- ContentIterators.cs
- UseLicense.cs
- TextClipboardData.cs
- TablePattern.cs
- GenericTextProperties.cs
- DoubleAnimationUsingPath.cs
- SafeEventLogReadHandle.cs
- MatrixTransform.cs
- RectangleHotSpot.cs
- BaseConfigurationRecord.cs
- TypeInitializationException.cs
- ListMarkerSourceInfo.cs
- PreProcessor.cs
- SerializationFieldInfo.cs
- Renderer.cs
- DataGridViewRowHeaderCell.cs
- MenuAutomationPeer.cs
- DesignerAdapterUtil.cs
- LinqDataSourceContextEventArgs.cs
- Vector3D.cs
- ChineseLunisolarCalendar.cs
- ScriptHandlerFactory.cs
- InfoCardUIAgent.cs
- UnionCqlBlock.cs
- NotifyIcon.cs
- ReadOnlyMetadataCollection.cs
- ApplicationFileParser.cs
- TreeNodeCollectionEditorDialog.cs
- ProxyGenerator.cs
- WebBaseEventKeyComparer.cs
- PresentationTraceSources.cs
- RepeaterItemEventArgs.cs
- Crypto.cs
- LogicalExpr.cs
- DataTableClearEvent.cs
- Html32TextWriter.cs
- PropertyManager.cs
- _Semaphore.cs
- XmlUtf8RawTextWriter.cs
- ColorConverter.cs
- DependencyProperty.cs
- DrawingVisualDrawingContext.cs
- DesignerExtenders.cs
- DbParameterHelper.cs
- _ProxyChain.cs
- WebBrowserNavigatedEventHandler.cs
- MetadataStore.cs
- _NegoState.cs
- ObjectReaderCompiler.cs
- ToolBar.cs
- Win32Interop.cs
- CompilerCollection.cs
- WebSysDefaultValueAttribute.cs
- DataObjectMethodAttribute.cs
- TemplateColumn.cs
- shaper.cs
- SqlDataSourceView.cs
- ByteFacetDescriptionElement.cs
- Margins.cs
- Label.cs
- SqlDataSourceStatusEventArgs.cs
- DynamicRendererThreadManager.cs
- TryCatchDesigner.xaml.cs
- ReliabilityContractAttribute.cs
- XamlTypeMapper.cs
- WindowsRegion.cs
- SchemaSetCompiler.cs
- TrackingStringDictionary.cs
- DocumentXmlWriter.cs
- AdornerHitTestResult.cs
- XhtmlBasicFormAdapter.cs
- DataGridViewTextBoxCell.cs
- OrderedDictionary.cs
- Mutex.cs
- DynamicAttribute.cs
- CompilerResults.cs
- SchemaElementDecl.cs
- QilChoice.cs
- CodeIdentifiers.cs
- AutomationPatternInfo.cs
- BitmapEffectOutputConnector.cs
- QuotaThrottle.cs
- InputReport.cs
- InputQueueChannelAcceptor.cs
- TypeDescriptor.cs
- OdbcParameterCollection.cs
- XmlStreamedByteStreamReader.cs
- ProfilePropertySettingsCollection.cs