RAD PDF服务消息工作者线程未知异常

时间:2013-04-21 12:44:34

标签: c# asp.net file iis permissions

我尝试通过RadPdf控件打开我的PDF,但是我得到渲染错误。我检查事件查看器并获取以下数据: 解决问题我必须创建C:\WINDOWS\TEMP\RadPdfTemp\和管理员每一段时间清空临时文件并删除此文件夹,我尝试在我的网站上创建具有所需权限的文件夹,但仍然得到相同的错误! !!


 this.rad_pdf.CreateDocument("Document Name", pdfData);

我得到pdfData通过:

 private byte[] AddReportToResponse(LocalReport followsReport)
    {
        string mimeType;
        string encoding;
        string extension;
        string[] streams = new string[100];
        Warning[] warnings = new Warning[100];
        byte[] pdfStream = followsReport.Render("PDF", "", out mimeType, out encoding, out extension, out streams, out warnings);


        return pdfStream;
    }

Event Type: Error
Event Source:   RAD PDF
Event Category: None
Event ID:   0
Date:       4/21/2013
Time:       2:33:50 PM
User:       N/A
Computer:   -----
Description:
Event Category
-----------------
PdfService

Event Description
-----------------
RAD PDF Service Message Worker Thread Unknown Exception
Exception Type:
System.IO.DirectoryNotFoundException
Exception Message:
Could not find a part of the path 'C:\WINDOWS\TEMP\RadPdfTemp\p476.tmp'.
Exception Stack Trace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
   at #Ew.#Rw.#ix()
   at #Ew.#Rw.#9w()

Event User
-----------------
NT AUTHORITY\SYSTEM

Event Version
-----------------
2.12.0.0

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

1 个答案:

答案 0 :(得分:3)

您应该检查临时文件夹是否存在,否则在打开PDF文件之前创建它。这将确保文件夹在那里并且不会抛出任何异常。

string tempDirectory = Path.Combine(Path.GetTempPath(), "RadPdfTemp");

if (!Directory.Exists(tempDirectory))
    Directory.CreateDirectory(tempDirectory);

this.rad_pdf.CreateDocument("Document Name", pdfData);