【发布时间】:2019-01-16 17:58:38
【问题描述】:
我正在尝试从 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();
}
}
但是编译器在抱怨
命名空间中不存在类型或命名空间 Printing 系统(您是否缺少程序集参考)?
我该如何解决这个问题?
编辑:如何为命令行编译的应用程序添加引用(不是 Visual Studio)
【问题讨论】:
-
"您是否缺少程序集引用?"是的,你是。你可以猜到它的名字。
-
右键单击“References”并添加“System.Printing”命名空间。我认为这将在 .NET Framework 3.0 及更高版本中可用。
-
如何为命令行编译的应用程序执行此操作(没有 Visual Studio,我使用的是 Notepad++ 和 Csc 编译器)?
-
@quickCoder 下载 Visual Studio Code 或 Visual Studio Community,它们是 Visual Studio 的免费版本。在你的情况下,我会选择社区。span>
-
@MagnusKarlsson 我目前的开发环境在我可以下载的内容方面有点有限,所以我尝试使用命令提示符。