tags:

views:

17

answers:

1

Hello,

I have an ASP.NET application on my local machine that works. This application takes an SVG file and creates a PNG from it using inkscape. I have tried to migrate that application to my production server. Oddly, the png creation is not working. The really strange part is, an Exception is not being thrown either. I have taken the command line parameters that are being created and copied and pasted them into the command line environment and they work. For instance, here is the line:

inkscape.exe -f "C:\inetpub\wwwroot\MyTest\sample.svg" -e "C:\inetpub\wwwroot\MyTest\sample.png"

I thought it was something simple, so I extracted the code into a sample web project. This project just converts a .svg to a .png. Once again, it worked in my local environment, but not in the production environment. Here is the code:

protected void executeButton_Click(object sender, EventArgs e)
{
    try
    {
        string sourceFile = Server.MapPath("svg") + "\\" + ConfigurationManager.AppSettings["sourceFile"];
        string targetFile = Server.MapPath("png") + "\\" + ConfigurationManager.AppSettings["targetFile"];

        string args = "-f \"" + sourceFile + "\" -e \"" + targetFile + "\" -w100 -h40";
        string inkscape = ConfigurationManager.AppSettings["inkscapeExe"];

        // Generate the png via inkscape
        ProcessStartInfo inkscapeInfo = new ProcessStartInfo(inkscape, args);
        Process inkscape = Process.Start(inkscapeInfo);
        inkscape.WaitForExit(5000);

        runLiteral.Text = "Success!<br />" + args;
    }
    catch (Exception ex)
    {
        runLiteral.Text = ex.GetType().FullName + "<br />" + ex.Message + "<br />" + ex.StackTrace;
    }
}

Can someone tell me what I'm doing wrong?

Thank you!

A: 

A couple things to check:

  • Make sure that the application pool identity for the web application (found in IIS, usually NetworkService) has permissions to execute inkscape.exe
  • If that is fine, check to make sure that the directory grants Modify permissions to the apppool identity on the directory(ies) you are writing the PNG to ("C:\inetpub\wwwroot\MyTest")
  • Alternatively, you can use impersonation to run the executable under a specific Windows account.
Keith