Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RAD PDF服务消息工作线程未知异常_C#_Asp.net_File_Iis_Permissions - Fatal编程技术网

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

C# RAD PDF服务消息工作线程未知异常,c#,asp.net,file,iis,permissions,C#,Asp.net,File,Iis,Permissions,我试图通过控件打开我的PDF,但出现了渲染错误。我检查事件查看器并获得以下数据: 要解决此问题,我必须创建C:\WINDOWS\TEMP\RadPdfTemp\,管理员每次清空TEMP并删除此文件夹,我尝试使用所需权限在我的网站中创建此文件夹,但仍会收到相同的错误 我通过以下方式获得pdfData: private byte[] AddReportToResponse(LocalReport followsReport) { string mimeType;

我试图通过控件打开我的PDF,但出现了渲染错误。我检查事件查看器并获得以下数据: 要解决此问题,我必须创建
C:\WINDOWS\TEMP\RadPdfTemp\
,管理员每次清空TEMP并删除此文件夹,我尝试使用所需权限在我的网站中创建此文件夹,但仍会收到相同的错误


我通过以下方式获得
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;
    }


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

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

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

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

澄清“管理员每段时间清空临时文件并删除此文件夹”可能有助于其他人帮助您。你这是什么意思?您的意思是手动创建
C:\WINDOWS\TEMP\RadPdfTemp
,暂时解决问题,但管理员(作业)会每隔一段时间清空
C:\WINDOWS\TEMP
,删除
RadPdfTemp
子文件夹?同样值得澄清,以帮助其他人帮助您:“我试图用所需权限在我的网站中创建此文件夹,但仍会收到相同的错误!!!“那么,当您尝试在web代码中创建
C:\WINDOWS\TEMP\RadPdfTemp
时,它被成功创建了吗?所需的权限是什么?我想是您在手动创建文件夹时设置的权限?您是否尝试在web代码中写出您正在创建的文件夹的路径,然后将其粘贴到WINDOWS Run…d中?”iLog或Windows资源管理器来确认它是否打开(如您所期望的)?@J0e3gan::
您的意思是手动创建C:\Windows\TEMP\RadPdfTemp,这会暂时解决问题,但管理员(作业)会每隔一段时间清空C:\Windows\TEMP,删除RadPdfTemp子文件夹?
是的,这正是我所做的。
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.
string tempDirectory = Path.Combine(Path.GetTempPath(), "RadPdfTemp");

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

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