如何从发布应用程序调用exe [英] how to call exe from publish application

查看:91
本文介绍了如何从发布应用程序调用exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Web应用程序(vb.net中的代码)调用报表生成器的exe,但是通过代码工作得很好

但是当我将它发布在iis中时它不起作用然后它是不工作。

我已经给了读/写文件夹的权利



以下代码

 受保护的  Sub  Button1_Click(发件人 As  对象,e  As  EventArgs)
Dim p As New Process()
p.StartInfo.FileName = D:\ yourapplication.exe
p.Start()
结束 Sub





Plz建议我。

解决方案

请参阅我对问题和原始文档的评论: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx [ ^ ]。



对于某些文件的路径,可以在运行时根据用户输入或某些配置文件计算它们。你不能只使用硬编码的驱动器D(或C,无关紧要) - 谁知道每个特定系统上的内容是什么?并非所有系统都有D,并非所有系统都有C(它可能会让你感到惊讶,但事实就是如此)。对于您可以使用的一些有效目录,请参阅我过去的答案:

如何查找我的程序目录可执行目录),

如何查找我的程序目录当前目录,特殊文件夹



此外,它是一般来说,开始一个单独的过程通常不是一个好主意。流程是完全隔离的,通常不是为了沟通而设计的。



-SA


基于Web的应用程序使用 Server.MapPath [ ^ ]方法定义文件的路径。在另一个网站上,请看这里: Process.Start [ ^ ]方法:

MSDN写道:

注意



ASP.NET网页和服务器控制代码在Web服务器上的ASP.NET辅助进程的上下文中执行。如果在ASP.NET网页或服务器控件中使用Start方法,则新进程将在具有受限权限的Web服务器上执行。该过程不会在与客户端浏览器相同的上下文中启动,也无法访问用户桌面。


I want to call exe of report builder from web application (code in vb.net) but work well through code
but it doesn't work while i 'll publish it in iis then it's not work.
I have already give rights to folder of read/write

Code below

Protected Sub Button1_Click(sender As Object, e As EventArgs)
    Dim p As New Process()
    p.StartInfo.FileName = "D:\yourapplication.exe"
    p.Start()
End Sub



Plz suggest me.

解决方案

Please see my comment to the question and the original documentation: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx[^].

As to the paths to some files, they can always be calculated during runtime, based on user input or some configuration files. You cannot just use hard-coded drive "D" (or "C", does not matter) — who knows what is it on each particular system? Not all system have D, not all have C (it may come at surprise for you, but this is so). For some valid directories you can use, please see my past answers:
How to find my programs directory (executable directory),
How to find my programs directory (current directory, "special folders").

Besides, it's generally not a good idea to start a separate process at all. Processes are well-isolated and usually not designed to communicate.

—SA


Web based application uses Server.MapPath[^] method to define path to the file(s). On the other site, have a look here: Process.Start[^] method:

MSDN wrote:

Note

ASP.NET Web page and server control code executes in the context of the ASP.NET worker process on the Web server. If you use the Start method in an ASP.NET Web page or server control, the new process executes on the Web server with restricted permissions. The process does not start in the same context as the client browser, and does not have access to the user desktop.


这篇关于如何从发布应用程序调用exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆