Forum Bugs

"Cannot start process" when executing ConvertStrin

pmaugust
Getting the following error. Running web application .net 2.0.

Cannot start process because a file name has not been provided.
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.InvalidOperationException: Cannot start process because a file name has not been provided.

Source Error:

Line 36: xmlPrint.SetLog(Server.MapPath("VisionPrint.log"))
Line 37:
Line 38: If xmlPrint.ConvertString(myStringWriter.ToString(), Response.OutputStream()) Then
Line 39: Response.ContentType = "application/pdf"
Line 40: Else

Source File: I:\Innovation\ovIntegratedVisionPrint.aspx.vb Line: 38

Stack Trace:

[InvalidOperationException: Cannot start process because a file name has not been provided.]
System.Diagnostics.Process.Start() +732474
Prince.StartPrince(String args) +182
Prince.ConvertString(String xmlInput, Stream pdfOutput) +97
ovIntegratedVisionPrint.Page_Load(Object sender, EventArgs e) in I:\Innovation\ovIntegratedVisionPrint.aspx.vb:38
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

My application has a base XML file that gets transformed into browser friendly format, or into "Prince friendly" format. My code:

Dim strXmlFile As String = Server.MapPath("IntegratedView\ovIV-" & Request.QueryString("d") & ".xml")
Dim strXslFile As String = Server.MapPath("IntegratedView\VisionPrint.xslt")

' Load our XML file into the XmlDocument object.
Dim myXmlDoc As XmlDocument = New XmlDocument()
myXmlDoc.Load(strXmlFile)

' Load our XSL file into the XslTransform object.
Dim myXslDoc As XslCompiledTransform = New XslCompiledTransform()
myXslDoc.Load(strXslFile)

' Create a StringBuilder and then point a StringWriter at it.
' We'll use this to hold the output by the Transform method.
Dim myStringBuilder As StringBuilder = New StringBuilder()
Dim myStringWriter As StringWriter = New StringWriter(myStringBuilder)

' Transform the XML file using the XSL stylesheet
myXslDoc.Transform(myXmlDoc, Nothing, myStringWriter)

' Process the transformed XML thru Prince to create PDF
Dim xmlPrint As Prince = New Prince
xmlPrint.SetLog(Server.MapPath("VisionPrint.log"))

If xmlPrint.ConvertString(myStringWriter.ToString(), Response.OutputStream) Then
Response.ContentType = "application/pdf"
Else
Response.Write("<html><body><h2>Error generating PDF</h2></body></html>")
End If

I get no log, just the error. For verification, I removed the prince section and replaced with
Response.Write(myStringWriter.ToString())
The code ran. Did a view source, saved to disk, and ran that thru Prince application and it converted perfectly.

So, am I missing something really simple (I hope)??? :shock:
mikeday
When you call "New Prince", pass in the path to the prince.exe file, eg. "c:\program files\Prince\engine\bin\prince.exe".