2015-05-04 15 views
5

Używam NReco .PdfGenerator dla moich dokumentów PDF (ten komponent jest oparty na narzędziu WkHtmlToPdf), mój kod pozwala mi stworzyć pdf wywołujący funkcję z parametrami kontroler, akcja, model:NReco.PdfGenerator Rura została zakończona błędem na serwerze

public static byte[] GeneratePdfDocument(System.Web.Mvc.Controller controller, string viewName, object model) 
{ 
    string result; 
    controller.ViewData.Model = model; 
    using (StringWriter sw = new StringWriter()) 
    { 
     ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName); 
     ViewContext viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw); 
     viewResult.View.Render(viewContext, sw); 

     result = sw.ToString(); 
    } 

    return (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(result); 
} 

z tym kodem mogę utworzyć plik PDF z łatwością z moimi poglądami i to działa świetnie na moim środowiska rozwoju, ale na serwerze dostaję taki błąd:

The pipe has been ended. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.IOException: The pipe has been ended. 


[IOException: The pipe has been ended.] 
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +11185413 
System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count) +10770013 
System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count) +139 
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(String htmlFilePath, Byte[] inputBytes, String coverHtml, String outputPdfFilePath, Stream outputStream) +2166 

[Exception: Cannot generate PDF: The pipe has been ended.] 
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(String htmlFilePath, Byte[] inputBytes, String coverHtml, String outputPdfFilePath, Stream outputStream) +2734 
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml, Stream output) +51 
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml) +42 

Myślę, że to może być problem z uprawnieniami konfiguracja na moim IIS, jakiś pomysł?

Odpowiedz

11

Prawdopodobnie brakuje Pakietów redystrybucyjnych Visual C++ dla VS2013 (x86). Nawet jeśli twój serwer działa z 64-bitowym systemem Windows, musisz zainstalować pakiety C++ x86.

Powiązane problemy