我试图从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();
}
}但是编译器在抱怨
命名空间系统中不存在类型或命名空间打印(是否缺少程序集引用)?
我该如何解决这个问题?
编辑:如何添加命令行编译应用程序(不是Visual )的引用
发布于 2015-06-28 15:53:38
在命令行中,类似于csc /reference:lib\System.Printing.dll
原始答案
项目>添加引用,然后在“程序集>框架”下.
选择System.Printing。
通过搜索名称空间和“程序集”一词,您可以找到需要添加引用的程序集。就你而言:
System.Printing assembly
第二个结果来自MSDN,并指示可以在哪个程序集System.Printing中找到。
发布于 2015-06-28 15:54:30
从命令提示符创建公共引用
/reference:[alias=]filename
/reference:filename哪里
参数
文件名
包含程序集清单的文件的名称。若要导入多个文件,请为每个文件包含一个单独的/reference选项。
别名
一个有效的C#标识符,它将表示将包含程序集中所有命名空间的根命名空间。
来自VisualStudioCommunity2013(免费版本)的,右键单击解决方案中的“引用”文件夹,然后在那里浏览。


发布于 2015-06-28 15:53:44
您缺少程序集引用。添加对System.Printing.dll的引用。
https://stackoverflow.com/questions/31101704
复制相似问题