C# 错误 ;14和9;类型或命名空间名称';文件';找不到(是否缺少using指令或程序集引用?)

C# 错误 ;14和9;类型或命名空间名称';文件';找不到(是否缺少using指令或程序集引用?),c#,asp.net-mvc-3,C#,Asp.net Mvc 3,对于pdf writer和段落,我得到了相同的错误。我遇到了相同的问题,然后我找到了答案 首先,请确保iTextSharp.dll已添加到引用和 然后在主窗体的开头。加上这个 Document document = new Document(); MemoryStream stream = new MemoryStream(); try { PdfWriter pdfWriter = PdfW

对于pdf writer和段落,我得到了相同的错误。我遇到了相同的问题,然后我找到了答案

首先,请确保iTextSharp.dll已添加到引用和

然后在主窗体的开头。加上这个

Document document = new Document();
            MemoryStream stream = new MemoryStream();
            try
            {
                PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
                pdfWriter.CloseStream = false;

                document.Open();
                document.Add(new Paragraph("Hello World"));
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            document.Close();

            stream.Flush(); //Always catches me out
            stream.Position = 0; //Not sure if this is required
            return File(stream, "application/pdf");

iTextSharp.text负责文档对象

,您是否使用指令和程序集参考获得了相应的
?不,我不知道应该使用哪一个请告诉我me@ArslanSunny:看起来您正在使用iTextSharp。请参考项目中的dll并使用相关的iTextSharp命名空间。CTRL+。我会帮你的。也读一下这个。
using iTextSharp.text; 

using iTextSharp.text.pdf;