我已经引用了一些关于如何在stackoverflow上执行此操作的提及。WebService不运行exe
我试着从以下基准测试代码:
https://www.dotnetperls.com/process
How to run .exe file by my Webservice?
版本:框架3.5
VisualStudio2010
,当我跑我下面的代码在浏览器中,我看到要点击的项目符号。当我点击它时没有任何反应。我的exe只是找到一个xml文件并从中创建一个新文件。我想用一个web服务来运行exe。我的代码中是否存在某些内容?还有其他版本,我看到有更多的代码,但我尝试过,仍然没有运气[检查我的链接]
这是我的第一个webservice,所以我正在学习,因为我去。
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.IO
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://localhost/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
Dim File As String
<WebMethod()> _
Public Sub runExe()
Dim exe = "C:\WindowsApplication1\bin\Debug\WindowsApplication1.exe"
'Dim file = "C:\Test\test.xml"
Dim startInfo As New ProcessStartInfo()
startInfo.FileName = exe
'startInfo.Arguments = file
Process.Start(startInfo)
'REFERENCE: https://www.dotnetperls.com/process
End Sub
我也试过calling .exe from another .exe to run a webservice使用
ThreadPool.QueueUserWorkItem(Sub() Process.Start("C:\WindowsApplication1\bin\Debug\WindowsApplication1.exe"))
但EXE没有跑又名我没有看到在exe文件将其发送到文件夹路径创建新的文件。
也试过:
Dim processInfo = New ProcessStartInfo(exe)
Dim process__1 = Process.Start(ProcessInfo)
process__1.WaitForExit(5000)
Dim exitCode = process__1.ExitCode
process__1.Close()
Return
什么都没有发生
UPDATE:
没想到使用输出测试,以找出我的问题。我用下面的:
While Not process__1.StandardOutput.EndOfStream
Dim line As String = process__1.StandardOutput.ReadLine()
End While
'WindowsApplication1.vshost.exe'?你不是想要运行'WindowsApplication1.exe'吗?另外,你可以做一些调试来确认应用程序没有被执行吗?也许在应用程序中包含一些调试输出?或者当你在这里调用它时读取进程的输出?看起来很有可能是因为你没有捕获或者你的测试没有按照你自己的想法去做,而是因为一个很好的理由而失败。 – David
是的,这是错字。我会研究创建过程的输出。 @David – narue1992
此外,虽然这可能是显而易见的,但它经常值得提问,因为很多人都挂在这上面...您是否期望这个应用程序在* server *或* client *上运行? – David