我试图从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();
}
}
Run Code Online (Sandbox Code Playgroud)
但编译器抱怨
命名空间系统中不存在类型或命名空间打印(您是否缺少程序集引用)?
我该如何解决这个问题?
编辑:如何为命令行编译的应用程序(非Visual Studio)添加引用
从命令行的东西 csc /reference:lib\System.Printing.dll
原始答案
项目>添加参考,然后在'装配>框架'下.
选择System.Printing.
您可以通过Google搜索命名空间后跟单词"assembly"来找出需要添加引用的程序集.在你的情况下:
System.Printing assembly
第二个结果来自MSDN并指示可以找到哪个程序集System.Printing.
从命令提示符 创建公共参考
/reference:[alias=]filename
/reference:filename
Run Code Online (Sandbox Code Playgroud)
哪里
争论
filename
包含程序集清单的文件名。要导入多个文件,请为每个文件包含一个单独的/ reference选项。别名
一个有效的C#标识符,它将代表一个根名称空间,该名称空间将包含程序集中的所有名称空间。
从Visual Studio Community 2013(免费版)中,在解决方案中的“引用”文件夹上单击鼠标右键,然后在其中浏览。

| 归档时间: |
|
| 查看次数: |
7967 次 |
| 最近记录: |