PDFsharp:名称 'Process' 在当前上下文中不存在
PDFsharp: The name 'Process' does not exist in current context
我一直在尝试安装 PDFsharp 库来编写 PDF 记录,但遇到了一个问题。它一直说该流程在当前上下文中不存在。我做了一个 google 并且没有运气和修补程序来查看我是否可以让它工作但也没有运气。下面是我用来测试库的代码(从 PDFsharp wiki 中提取)
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
string filename = "HelloWorld.pdf";
document.Save(filename);
process.Start(filename);
这些是我目前使用的组件。
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
我可能是傻了,但有人能看出我做错了什么来抛出这个错误吗?
这一行是错误的
process.Start(filename);
与PDFsharp
无关。你必须解决这个问题
using System.Diagnostics;
...
Process.Start(filename);
如果您不想添加 "using" 指令:
System.Diagnostics.Process.Start(filename);
我一直在尝试安装 PDFsharp 库来编写 PDF 记录,但遇到了一个问题。它一直说该流程在当前上下文中不存在。我做了一个 google 并且没有运气和修补程序来查看我是否可以让它工作但也没有运气。下面是我用来测试库的代码(从 PDFsharp wiki 中提取)
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
string filename = "HelloWorld.pdf";
document.Save(filename);
process.Start(filename);
这些是我目前使用的组件。
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
我可能是傻了,但有人能看出我做错了什么来抛出这个错误吗?
这一行是错误的
process.Start(filename);
与PDFsharp
无关。你必须解决这个问题
using System.Diagnostics;
...
Process.Start(filename);
如果您不想添加 "using" 指令:
System.Diagnostics.Process.Start(filename);