<PackageReference Include="System.Drawing.Common" Version="10.0.0-preview.2.25163.9" />

InvalidPrinterException

Represents the exception that is thrown when you try to access a printer using printer settings that are not valid.
using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Security; namespace System.Drawing.Printing { [Serializable] [NullableContext(1)] [Nullable(0)] [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class InvalidPrinterException : SystemException { [Obsolete(DiagnosticId = "SYSLIB0051")] protected InvalidPrinterException(SerializationInfo info, StreamingContext context) : base(info, context) { } [Obsolete(DiagnosticId = "SYSLIB0051")] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("settings", null); } public InvalidPrinterException(PrinterSettings settings) : base(GenerateMessage(settings)) { } private static string GenerateMessage(PrinterSettings settings) { if (!settings.IsDefaultPrinter) try { return System.SR.Format(System.SR.InvalidPrinterException_InvalidPrinter, settings.PrinterName); } catch (SecurityException) { return System.SR.Format(System.SR.InvalidPrinterException_InvalidPrinter, System.SR.CantTellPrinterName); } return System.SR.InvalidPrinterException_NoDefaultPrinter; } } }