简体   繁体   中英

Cannot resolve System.Drawing.Printing

I am trying to display a list of installed printers on the local computer using the method described on MSDN ...

using System.Drawing;
using System.Drawing.Printing;

namespace SandBox
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                Console.WriteLine(PrinterSettings.InstalledPrinters[i]);        
            }

            Console.ReadLine();
        }
    }
}

The problem is on the Using statement, the 'Printing' namespace cannot be resolved. Is there an additional reference I am missing?

UPDATE: I have added references to System.Drawing & System.Printing but this does not resolve the problem.

为了使用System.Drawing.Printing命名空间,您必须引用程序集System.Drawing.dll

In .Net Core and .Net Standard , System.Drawing.Printing can be installed via nuget Microsoft.Windows.Compatibility

Docs: https://docs.microsoft.com/en-us/dotnet/core/porting/windows-compat-pack

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM