并使用Server.Mappath运行从ASP.NET应用程序的命令行实用工具 [英] Server.MapPath and running a command line utility from an ASP.NET application
问题描述
我需要使用过程
来运行一个ASP.NET应用程序的可执行文件。该.exe文件位于ASP.NET项目中 - 'ProjectRoot /工具/ utility.exe
I need to run an executable from an ASP.NET app using Process
. The .exe file is located inside the ASP.NET project - 'ProjectRoot/Utilities/utility.exe'
为什么这个code无法运行它:
Why does this code fail to run it:
string path = Server.MapPath("/Utilities/");
string args = " etc etc";
Process p = Process.Start(new ProcessStartInfo(path + "utility.exe", args));
p.WaitForExit(3000);
我试过\\\\ utility.exe
了。
推荐答案
有几件事情在这里检查。
There's a few things to check here.
的第一件事就是确保字符串路径=使用Server.Mappath(/工具/);
是一个有效的路径和工具.EXE
在正确的位置。
The first thing is to ensure that string path = Server.MapPath("/Utilities/");
is a valid path and that utility.exe
is in the correct location.
您说,它不抛出一个异常,那么 utility.exe
的调用的应的至少是有效的。然而, utility.exe
的可能的燕子又遇到任何异常它(取决于它如何是codeD),这可能是为什么似乎并不奏效。
You said that it does not throw an exception, so the invocation of utility.exe
should at least be valid. However, utility.exe
may swallow any exceptions it in turn encounters (depends on how it was coded), which may be why it does not appear to be working.
在最重要的是,你的 ARGS
变量可指定一个文件或一些其他的资源, utility.exe
访问。如果它吞下例外,它可以掩盖权限错误如果应用程序池标识不具有访问种源。
On top of that, your args
variable may be specifying a file or some other resource that utility.exe
accesses. If it does swallow exceptions, it could be masking a permissions error if the application pool identity does not have access to the resouce.
这篇关于并使用Server.Mappath运行从ASP.NET应用程序的命令行实用工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!