Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Printing / InvalidPrinterException.cs / 1305376 / InvalidPrinterException.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Drawing.Printing { using System.Diagnostics; using System; using System.Security; using System.Security.Permissions; using System.Runtime.Serialization; using System.ComponentModel; using System.Runtime.InteropServices; using Microsoft.Win32; ////// /// [Serializable()] public class InvalidPrinterException : SystemException { private PrinterSettings settings; ////// Represents /// the /// exception that is thrown when trying to access a printer using invalid printer settings. /// ////// /// public InvalidPrinterException(PrinterSettings settings) : base(GenerateMessage(settings)) { this.settings = settings; } ////// Initializes a new instance of the ///class. /// protected InvalidPrinterException(SerializationInfo info, StreamingContext context) : base (info, context) { settings = (PrinterSettings)info.GetValue("settings", typeof(PrinterSettings)); } /// [SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info==null) { throw new ArgumentNullException("info"); } IntSecurity.AllPrinting.Demand(); info.AddValue("settings", settings); base.GetObjectData(info, context); } static string GenerateMessage(PrinterSettings settings) { if (settings.IsDefaultPrinter) { return SR.GetString(SR.InvalidPrinterException_NoDefaultPrinter); } else { try { return SR.GetString(SR.InvalidPrinterException_InvalidPrinter, settings.PrinterName); } catch (SecurityException) { return SR.GetString(SR.InvalidPrinterException_InvalidPrinter, SR.GetString(SR.CantTellPrinterName)); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Drawing.Printing { using System.Diagnostics; using System; using System.Security; using System.Security.Permissions; using System.Runtime.Serialization; using System.ComponentModel; using System.Runtime.InteropServices; using Microsoft.Win32; ////// /// [Serializable()] public class InvalidPrinterException : SystemException { private PrinterSettings settings; ////// Represents /// the /// exception that is thrown when trying to access a printer using invalid printer settings. /// ////// /// public InvalidPrinterException(PrinterSettings settings) : base(GenerateMessage(settings)) { this.settings = settings; } ////// Initializes a new instance of the ///class. /// protected InvalidPrinterException(SerializationInfo info, StreamingContext context) : base (info, context) { settings = (PrinterSettings)info.GetValue("settings", typeof(PrinterSettings)); } /// [SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info==null) { throw new ArgumentNullException("info"); } IntSecurity.AllPrinting.Demand(); info.AddValue("settings", settings); base.GetObjectData(info, context); } static string GenerateMessage(PrinterSettings settings) { if (settings.IsDefaultPrinter) { return SR.GetString(SR.InvalidPrinterException_NoDefaultPrinter); } else { try { return SR.GetString(SR.InvalidPrinterException_InvalidPrinter, settings.PrinterName); } catch (SecurityException) { return SR.GetString(SR.InvalidPrinterException_InvalidPrinter, SR.GetString(SR.CantTellPrinterName)); } } } } } // 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
- VerificationException.cs
- RegexWorker.cs
- Line.cs
- XPathNavigatorKeyComparer.cs
- LineUtil.cs
- ServiceModelSectionGroup.cs
- Expression.cs
- HMACSHA384.cs
- ProfessionalColors.cs
- _CacheStreams.cs
- RuntimeHelpers.cs
- ActivationServices.cs
- CodeExporter.cs
- DuplicateContext.cs
- AspNetHostingPermission.cs
- PropertyEmitterBase.cs
- CmsInterop.cs
- ConfigXmlWhitespace.cs
- AssociationEndMember.cs
- ObjectDataSourceView.cs
- FontSizeConverter.cs
- NavigationPropertyEmitter.cs
- SqlProviderManifest.cs
- CodePageUtils.cs
- SecurityContext.cs
- Font.cs
- XmlNode.cs
- xmlsaver.cs
- SaveFileDialog.cs
- ScriptingScriptResourceHandlerSection.cs
- VectorConverter.cs
- StylusShape.cs
- FontFaceLayoutInfo.cs
- GridEntryCollection.cs
- ReferencedType.cs
- ToolStripItemTextRenderEventArgs.cs
- ListComponentEditorPage.cs
- StaticDataManager.cs
- ReadOnlyMetadataCollection.cs
- DataPointer.cs
- ByteConverter.cs
- CrossSiteScriptingValidation.cs
- SQLInt16.cs
- Int16KeyFrameCollection.cs
- DrawItemEvent.cs
- SqlDataSource.cs
- ObjectToken.cs
- OrderByQueryOptionExpression.cs
- ProcessInputEventArgs.cs
- StringFreezingAttribute.cs
- MailHeaderInfo.cs
- SocketStream.cs
- HtmlLabelAdapter.cs
- ProjectionPlan.cs
- SchemaDeclBase.cs
- RuleRefElement.cs
- ViewStateException.cs
- CompilerState.cs
- KeyConverter.cs
- VirtualPath.cs
- SqlGatherConsumedAliases.cs
- Switch.cs
- JournalNavigationScope.cs
- LZCodec.cs
- sqlstateclientmanager.cs
- InvokeProviderWrapper.cs
- SafeRegistryKey.cs
- itemelement.cs
- MailDefinition.cs
- ParameterCollection.cs
- SizeKeyFrameCollection.cs
- Convert.cs
- StringCollection.cs
- InstanceData.cs
- XmlLanguageConverter.cs
- SiteMapNodeItem.cs
- ObjectDisposedException.cs
- Journal.cs
- UrlMappingCollection.cs
- SharedPersonalizationStateInfo.cs
- XPathDocument.cs
- CommandEventArgs.cs
- Registry.cs
- ValueTypeFixupInfo.cs
- NumberSubstitution.cs
- NodeInfo.cs
- NotImplementedException.cs
- CompressedStack.cs
- GeometryHitTestParameters.cs
- ConditionalAttribute.cs
- StrongNamePublicKeyBlob.cs
- ThreadInterruptedException.cs
- CodeSubDirectoriesCollection.cs
- WebRequestModuleElement.cs
- WebPartCloseVerb.cs
- ConsumerConnectionPointCollection.cs
- DynamicMetaObjectBinder.cs
- ObfuscateAssemblyAttribute.cs
- AspNetSynchronizationContext.cs
- JavaScriptObjectDeserializer.cs