Process.Start in Azure Website(Process.Start 在 Azure 网站中)
问题描述
I have an ASP.NET MVC 5 app where I need to invoke wkhtml2pdf.exe in my Azure website using Process.Start
. Locally everthing works fine. But it seems my app stuck at Process.Start
line. Is starting a process is supported on Azure?
ramiramilu's answer is actually not correct. You can run any exe you want (check this for example). The problem you are hitting is not in running an exe, it's something specific to wkhtml2pdf.exe
itself. That exe uses a bunch of GDI+
calls on Windows for rendering the PDF and that is what's not allowed in Azure Websites sandbox (the GDI+
calls, not running an exe).
Using a WebJob won't help either because WebJobs run in the same context as the site which means under the same sandbox.
Edit:
There is nothing special to how you would launch an external process on Azure Websites than how you would do it normally with C#. Again the problem you are facing is with wkhtml2pdf.exe
and not with the general concept of launching a process.
Here is a sample that you can try that launches cmd.exe
and reads what is written on stdout
var processStartInfo = new ProcessStartInfo()
{
Arguments = "/c echo "test"",
FileName = @"c:windowssystem32cmd.exe",
RedirectStandardOutput = true,
UseShellExecute = false
};
var process = Process.Start(processStartInfo);
using (var streamReader = new StreamReader(process.StandardOutput.BaseStream))
{
ViewBag.MessageFromExe = streamReader.ReadToEnd();
}
ViewBag.MessageFromExe
will have the value "test"
you can verify that on your view and you can run that just fine in Azure Websites
这篇关于Process.Start 在 Azure 网站中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Process.Start 在 Azure 网站中
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01