我正在尝试从 MSDN 运行以下示例:
using System.Printing;
public class PrintTest {
public static void Main(string[] args)
{
// Create the printer server and print queue objects
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();
// Call AddJob
PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob();
// Write a Byte buffer to the JobStream and close the stream
Stream myStream = myPrintJob.JobStream;
Byte[] myByteBuffer = UnicodeEncoding.Unicode.GetBytes("This is a test string for the print job stream.");
myStream.Write(myByteBuffer, 0, myByteBuffer.Length);
myStream.Close();
}
}
但编译器在提示
The type or namespace Printing does not exist in the namespace System(are you missing an assembly reference) ?
我该如何解决这个问题?
EDIT: How do I add a reference for command line compiled application ( Not Visual Studio)
最佳答案
从命令行类似于 csc /reference:lib\System.Printing.dll
原始答案
项目 > 添加引用,然后在“程序集 > 框架”下。
选择 System.Printing。
您可以通过谷歌搜索命名空间后跟“程序集”一词来找出需要添加引用的程序集。在你的情况下:System.Printing assembly
第二个结果来自 MSDN,指示可以在哪个程序集中找到 System.Printing。
关于c# - System.Printing 未找到(C#)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31101704/