c# - System.Printing 未找到(C#)?

标签 c# dll printing

我正在尝试从 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/

相关文章:

c# - 使用 forEach 迭代 IQueryable 与调用 ToList() 然后执行 forEach - 性能

c# - 为什么没有正确引发数据绑定(bind)完成事件?

windows - 在 Windows 上安装共享 DLL 的位置

c - LdrLoadDll 状态失败

linux - 将文件内容复制到目标文件。在目标文件中最后一次匹配模式之后。原始文件的内容显示在目标文件的下一行

c# - 我可以在没有泛型的情况下定义/约束成员实现两个接口(interface)吗?

c++ - 打印 DLL 中函数的代码

java - 纵向打印数组 : java

HTML/CSS - 为什么打印时背景颜色变成白色?

c# - 使用 WIX 3.5 在 IIS 7/7.5 中添加/启用处理程序映射