Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CompMod / System / ComponentModel / LicenseException.cs / 1 / LicenseException.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel {
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Security.Permissions;
///
/// Represents the exception thrown when a component cannot be granted a license.
///
[HostProtection(SharedState = true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] // must not, a Type is required in all constructors.
[Serializable]
public class LicenseException : SystemException {
private Type type;
private object instance;
///
/// Initializes a new instance of the class for the
/// specified type.
///
public LicenseException(Type type) : this(type, null, SR.GetString(SR.LicExceptionTypeOnly, type.FullName)) {
}
///
/// Initializes a new instance of the class for the
/// specified type and instance.
///
public LicenseException(Type type, object instance) : this(type, null, SR.GetString(SR.LicExceptionTypeAndInstance, type.FullName, instance.GetType().FullName)) {
}
///
/// Initializes a new instance of the class for the
/// specified type and instance with the specified message.
///
public LicenseException(Type type, object instance, string message) : base(message) {
this.type = type;
this.instance = instance;
HResult = HResults.License;
}
///
/// Initializes a new instance of the class for the
/// specified innerException, type and instance with the specified message.
///
public LicenseException(Type type, object instance, string message, Exception innerException) : base(message, innerException) {
this.type = type;
this.instance = instance;
HResult = HResults.License;
}
///
/// Need this constructor since Exception implements ISerializable.
///
protected LicenseException(SerializationInfo info, StreamingContext context) : base (info, context) {
type = (Type) info.GetValue("type", typeof(Type));
instance = info.GetValue("instance", typeof(object));
}
///
/// Gets the type of the component that was not granted a license.
///
public Type LicensedType {
get {
return type;
}
}
///
/// Need this since Exception implements ISerializable and we have fields to save out.
///
[SecurityPermission(SecurityAction.Demand, SerializationFormatter=true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info == null) {
throw new ArgumentNullException("info");
}
info.AddValue("type", type);
info.AddValue("instance", instance);
base.GetObjectData(info, context);
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlChildEnumerator.cs
- EventOpcode.cs
- DataGrid.cs
- CompositeCollection.cs
- MobileControlsSection.cs
- StorageSetMapping.cs
- controlskin.cs
- XmlSchemaSimpleTypeRestriction.cs
- UIElementPropertyUndoUnit.cs
- HasActivatableWorkflowEvent.cs
- DynamicDataResources.Designer.cs
- AnimationClockResource.cs
- ObjectQuery.cs
- QilUnary.cs
- TokenBasedSetEnumerator.cs
- SafeWaitHandle.cs
- ExceptionRoutedEventArgs.cs
- ImageBrush.cs
- DBBindings.cs
- SqlTransaction.cs
- Int32RectConverter.cs
- Int64KeyFrameCollection.cs
- securestring.cs
- EventLogEntryCollection.cs
- ServiceContractViewControl.Designer.cs
- ToolTipAutomationPeer.cs
- HScrollProperties.cs
- log.cs
- JavascriptXmlWriterWrapper.cs
- ErrorEventArgs.cs
- HtmlWindowCollection.cs
- Decorator.cs
- QilLoop.cs
- InvokeMethodActivityDesigner.cs
- SiteMapHierarchicalDataSourceView.cs
- ShapeTypeface.cs
- EmptyStringExpandableObjectConverter.cs
- GridViewRowEventArgs.cs
- ViewKeyConstraint.cs
- _DisconnectOverlappedAsyncResult.cs
- METAHEADER.cs
- MobileResource.cs
- CheckBoxField.cs
- CaretElement.cs
- CodeExpressionStatement.cs
- DataShape.cs
- TextRangeAdaptor.cs
- InkPresenterAutomationPeer.cs
- DebugInfoExpression.cs
- HtmlCalendarAdapter.cs
- ExpressionConverter.cs
- StretchValidation.cs
- RadioButtonPopupAdapter.cs
- XpsS0ValidatingLoader.cs
- ErrorFormatter.cs
- XmlDataLoader.cs
- TransportSecurityBindingElement.cs
- DataListItemCollection.cs
- EventHandlersStore.cs
- ApplicationHost.cs
- ItemsPanelTemplate.cs
- dataprotectionpermissionattribute.cs
- RegionInfo.cs
- SqlUtil.cs
- AppDomain.cs
- AutomationPeer.cs
- SqlBulkCopy.cs
- ParameterBinding.cs
- DecoderBestFitFallback.cs
- DeadCharTextComposition.cs
- selecteditemcollection.cs
- TableSectionStyle.cs
- ProcessHostServerConfig.cs
- TextRunCache.cs
- RepeaterCommandEventArgs.cs
- TextSelectionProcessor.cs
- FamilyMapCollection.cs
- Interlocked.cs
- InertiaTranslationBehavior.cs
- QilChoice.cs
- SafeMILHandleMemoryPressure.cs
- TextEndOfParagraph.cs
- ToolStripRenderer.cs
- Funcletizer.cs
- HotSpot.cs
- XmlJsonWriter.cs
- PerfCounterSection.cs
- WebPartPersonalization.cs
- PenCursorManager.cs
- StreamGeometryContext.cs
- StaticFileHandler.cs
- ValidationManager.cs
- InfiniteTimeSpanConverter.cs
- Int32AnimationUsingKeyFrames.cs
- SessionState.cs
- DataGridViewSortCompareEventArgs.cs
- StyleCollection.cs
- SqlDependencyListener.cs
- XmlAttributeOverrides.cs
- ProjectionCamera.cs