无法从ASP.NET使用Inkscape生成的文件 [英] Unable to generate file from ASP.NET with inkscape
问题描述
我有我的工作的本地计算机上的ASP.NET应用程序。此应用程序需要一个SVG文件,并使用Inkscape的从它创建了一个PNG。我曾尝试到该应用程序迁移到我的生产服务器。奇怪的是,PNG创作是行不通的。真是个奇怪的部分是,一个例外
不被抛出两种。我已正在创建和复制并粘贴他们进入命令行环境的命令行参数和他们的工作。举例来说,这里是行:
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"
我还以为是简单的东西,所以我提取code到样品Web项目。这个项目只是一个转换到名为.svg的.png。再次,它的工作在我当地的环境,而不是在生产环境。这里是code:
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?
感谢您!
推荐答案
几件事情要检查:
- 请确保该Web应用程序(在IIS中,通常是网络服务中找到)的应用程序池标识具有权限执行inkscape.exe
- 如果是罚款,检查以确保该目录补助上的目录(IES)你正在写的巴纽(C:\\的Inetpub \\ wwwroot的\\ MyTest的)修改权限的应用程序池的身份
- 另外,你可以使用模拟在一个特定的Windows帐户运行可执行文件。
这篇关于无法从ASP.NET使用Inkscape生成的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!