我可以使用 Silverlight 应用程序在服务器中运行 .EXE 文件吗?
我认为这将是一项非常简单的任务,所以我认为我是弱智或类似的东西。我想部署一个遵循以下步骤的测试应用程序:
- 用户使用浏览器打开 Silverlight 应用程序
- 用户填写 Silverlight 表单并单击“确定”按钮。
- 按钮回调准备要作为参数传递给 .EXE 程序的表单。
- program.exe - 参数被执行。如果一切顺利,则会在已知路径中生成 result.txt。
- Silverlight 应用程序报告 result.txt
到目前为止,我唯一的问题是第四步,因为如果没有 System.Diagnostics.Process,我无法执行 .exe 程序。我尝试过 COM 解决方案,但对于此测试来说它不是一个好的解决方案。
I thought this would be a very easy task, so I think I´m retarded or something like that. I want to deploy a test application which follows this steps:
- The user opens a Silverlight application using the browser
- The user fills a Silverlight form and clicks on a "OK" button.
- The button callback prepares the form to be passed as an argument to a .EXE program.
- program.exe -argument is executed. If everything goes right, a result.txt is generated in a known path.
- The Silverlight application reports result.txt
My only problem, by now, is the 4th step, because I can´t execute my .exe program without System.Diagnostics.Process. I've tried a COM solution, but it's not a good solution for this tests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您现在应该意识到,Silverlight 实际上是使用 .NET Framework 的子集在本地浏览器中运行,即使具有受信任状态,对执行本地代码的支持也有限。
公平地说... Silverlight 对此可能有些过分,但如果您希望这样做并且正在服务器上运行该进程:
创建一个 DomainService 并添加一个单个 Invoke 方法如下所示:
[调用]
public string RunProcess( args ... )
创建一个按钮,调用 RunProcess 上的 Invoke 方法并传入参数。与 Silverlight 中的所有服务调用一样,这是一个异步回调,您需要连接一个 lambda 以在准备就绪时获取结果。
As you should realize by now, Silverlight is actually running inside the browser locally using a subset of the .NET Framework with somewhat limited support for executing local code even with trusted status.
To be fair ... Silverlight may be over-kill for this, but if you wish to do it and you are running the process on the server:
Create a DomainService and add a single Invoke method that looks like this:
[Invoke]
public string RunProcess( args ... )
Create a button that calls the Invoke method on RunProcess and passes in the parameters. As with all service calls in Silverlight this is an async callback and you will want to hook up a lambda to get the result when it is ready.
您是否考虑过在服务器上运行 Windows 服务来监视指定目录中显示的文件,然后运行 EXE 来生成文本文件?您的 silverlight 进程可以只轮询输出目录,直到 txt 文件出现。
Have you considered running a Windows Service on the server which watches for a file to show up in a specified directory, and then runs the EXE to generate the text file? Your silverlight process could just poll the output directory until the txt file shows up.