找不到System.Printing(C#)? [英] System.Printing not found( C# )?

查看:170
本文介绍了找不到System.Printing(C#)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从MSDN运行以下示例:

I am trying to run the following example from 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) ?

如何解决此问题?


编辑 >:如何为命令行编译的应用程序(不是Visual Studio)添加引用

EDIT: How do I add a reference for command line compiled application ( Not Visual Studio)


推荐答案

从命令提示符
创建公共引用

From Command prompt Create a public reference

/reference:[alias=]filename
/reference:filename

其中


参数

Arguments

文件名

包含程序集清单的文件的名称。要导入多个文件,请为每个文件包含一个单独的/ reference选项。

filename
The name of a file that contains an assembly manifest. To import more than one file, include a separate /reference option for each file.

别名

有效的C#标识符,它将代表将包含以下内容的根名称空间:程序集中的所有名称空间。

alias
A valid C# identifier that will represent a root namespace that will contain all namespaces in the assembly.

cmd的Microsoft文档页面

来自Visual Studio Community 2013 (免费版)
右键单击引用文件夹在您的解决方案中浏览。

From Visual Studio Community 2013 (Free version) Right click References folder in your solution and browse for it there.

这篇关于找不到System.Printing(C#)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆