我有一个 asp.net 应用程序,它使用 process.start 来调用可执行文件(Graphviz)。一切在我的开发环境中运行良好,但是当我转向生产时,我无法运行该流程。详细信息如下。
我创建了这个简单的子来展示这个问题。
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim ProcessInfo As ProcessStartInfo
ProcessInfo = New ProcessStartInfo
'ProcessInfo.Domain = "xxxxxxx"
ProcessInfo.UserName = "xxxxxx"
Dim PwdString As String = "xxxxxxx"
Dim newPass As System.Security.SecureString
newPass = New System.Security.SecureString
For Each c As Char In PwdString
newPass.AppendChar(c)
Next c
ProcessInfo.Password = newPass
'ProcessInfo.FileName = """C:\Windows\System32\Notepad.exe"""
'ProcessInfo.FileName = """C:\Test.bat"""
ProcessInfo.FileName = """C:\Program Files (x86)\Graphviz2.30\bin\dot.exe"""
ProcessInfo.Arguments = " -Kdot -Tsvg C:\Test.dot -pC:\Test.svg"
ProcessInfo.RedirectStandardOutput = True
ProcessInfo.UseShellExecute = False
ProcessInfo.CreateNoWindow = True
Dim Process As Process
Process = New Process
Process.StartInfo = ProcessInfo
Process.Start()
'Wait until the process passes back an exit code
Process.WaitForExit()
Try
Dim ProcessResults As String = Process.StandardOutput.ReadToEnd
Output.Text = ProcessResults
Catch ex As Exception
Output.Text = ex.ToString
End Try
End Sub
这里有三种情况。首先,我正在测试仅启动记事本。
- 开发工程
- 生产工作(这是我可以从事生产工作的唯一情况)
其次,我创建了一个简单的批处理文件,可以在记事本中打开文档。 (记事本c:\test.dot)
第三,我正在调用 Graphviz 的 dot.exe。这就是我试图在另一个页面中工作的内容。
在生产无法正常工作的所有情况下,我都可以重现此行为
- 如果我将 impersonate = true 添加到我的 web.config,那么我不会收到任何错误。页面运行就像成功一样。
访问被拒绝
描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
Exception Details: System.ComponentModel.Win32Exception: Access is
denied
Source Error:
Line 36: Process = New Process
Line 37: Process.StartInfo = ProcessInfo
Line 38: Process.Start()
Line 39:
Line 40: 'Wait until the process passes back an exit code
Source File: C:\Inetpub\vhosts\leapfrogbi.com\httpdocs\test\ProcessStart.aspx.vb Line: 38
Stack Trace:
[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +2161
System.Diagnostics.Process.Start() +150
Test_ProcessStart.Page_Load(Object sender, EventArgs e) in C:\Inetpub\vhosts\leapfrogbi.com\httpdocs\test\ProcessStart.aspx.vb:38
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
我尝试了各种与安全相关的设置。目前,我的应用程序池正在以本地管理员的身份运行。我还尝试将每个人都添加到管理员组中,以查看安全性是否是根本问题。
另外,我正在使用 Plesk 来管理我的域。我已经广泛搜索了可能影响这种情况的任何选项,但尚未找到。同样,当进行简单的调用来启动记事本时,进程启动确实可以在生产中工作。如果没有更详细的日志,很难缩小范围。
预先感谢您提供的任何帮助。这让我抓狂。