进程在启动后立即停止(Process stops immediately after start)
希望您能够帮助我。 我正在使用MonoDevelop编写Raspberry Pi。
我想用C#执行一个python脚本并从中读取。
class Program { public static void Main(string[] args) { Process p = new Process(); p.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); p.StartInfo.FileName = "sudo"; p.StartInfo.Arguments = "python gpio.py"; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); } private static void OutputHandler(Object sender, DataReceivedEventArgs args) { Console.WriteLine(args.Data); } }
在调试时我可以看到进程已退出Click for image
但是在TaskManager中我可以看到,该进程仍在运行。 脚本也控制gpio引脚。 并且脚本控制引脚(Led on / off),即使“Process has exited”也是如此。 但我从redirectOutput得到任何东西。
为什么进程在启动后立即退出(脚本有一段时间为真。它不应该停止)? 这是执行脚本的正确方法吗?
如果我从终端执行Python脚本,它可以正常工作。 它不应该是脚本的错误。 如果我启动一个进程,例如FileName“libreoffice”,它也可以。该脚本位于“/ bin / Debug /”(文件夹)中的项目文件夹中。为任何人设置执行权限。
谢谢,
问候Hope you can help me. I'm coding on a Raspberry Pi with MonoDevelop.
I want to execute a python script with C# and read from it.
class Program { public static void Main(string[] args) { Process p = new Process(); p.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); p.StartInfo.FileName = "sudo"; p.StartInfo.Arguments = "python gpio.py"; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); } private static void OutputHandler(Object sender, DataReceivedEventArgs args) { Console.WriteLine(args.Data); } }
While Debugging i can see that the Process has exited Click for image
But in the TaskManager i can see, that the process is still running. Also the script controls the gpio pins. And the script controlls the pins (Led on/off), even if the "Process has exited" . But I dont get anything from redirectOutput.
Why does the Process immediately quits after starting (the script has a while true. it shouldn't stop)? Is this the right way to execute a script?
If I execute the Python script from the terminal, it works fine. It shouldn't be an error with the script. If I start a process e.g. FileName "libreoffice", it works too.The script is located in the project folder in "/bin/Debug/" (the folder) Permissions for execution are set for anyone.
Thanks,
Greetings
原文:https://stackoverflow.com/questions/38594892
最满意答案
部分问题是您多次传入多值参数。 例如,表达式的一部分会导致:
...&SOURCE=A&SOURCE=B&SOURCE=C...
您只能在网址中为每个参数设置一个值。
所以解决这个问题的办法是用逗号分隔这些值并将它们作为单个字符串传入。 然后,在子报表中,您需要再次解析它们。
"&SOURCE=" & join(Parameters!SOURCE.Value,",")
您可能会遇到其他问题,例如URL长度限制,但这会解决当前的问题。
Part of the problem is that you are passing in the multi-value parameters multiple times. For example, part of your expression would result in:
...&SOURCE=A&SOURCE=B&SOURCE=C...
You can only set one value per parameter in the URL.
So the solution to that would be to comma separate the values and pass them in as a single string. Then, in the subreport, you would need to parse them out again.
"&SOURCE=" & join(Parameters!SOURCE.Value,",")
You may run into additional issues such as URL length limitations, but this will fix the immediate problem.
相关问答
更多-
您是否尝试过使用javascript和window.open在文本框的“转到URL”操作中打开新窗口? 例如: ="javascript:void(window.open('http://myserver/mypath/myasppage.html', '_blank'))" 看看这篇文章的更多信息。 Have you tried using javascript and window.open to open a new window in the Go To URL action of the tex ...
-
我遇到过类似的问题。 需要明确的是,从SSRS的角度来看,这不是问题。 SSRS认为这是正确的粗略行动。 我如何解决这个问题的方法是做以下事情: 您需要修改预先填充@Unit参数的查询。 在下面的代码中,我说“@Unit Script”我引用当前运行的SQL脚本来预先填充@Unit参数。 With Unit_CTE as ( --Insert @Unit Script here ) , Count_of_Units as ( Select Count(1) as Unit_Count From ...
-
使用主数据集中的列作为子报表中的多值参数(Using column from main dataset as multi-value parameter in subreport)[2023-07-23]
在您调用子报告的Action中,映射到shippingIDs_sub的位置,只要数据集中的值为NULL,就使用表达式传递一些有效值。 =IIF(IsNothing(Fields!ShippingID.value),"Some Valid Value",Fields!ShippingID.value) 至于这个: 有没有办法过滤掉NULL并仅为现有ID运行子报表? 不,您无法关闭转到子报表的功能,但您可以通过更改用户点击的内容来“隐藏”它,使其看起来不像是可点击的。 例如,在我们的报告中,当某些内容可以点击 ... -
在ASP.net页面上的SSRS报告中正确传递我的参数(Properly passing my parameters in SSRS report on ASP.net page)[2022-06-16]
我假设您的第一个代码片段是您正在使用的实际代码,而不是代码的一般形式的模型。 我进一步假设你有变量叫做fprogram和cperiod 。 您需要构建查询字符串以反映您希望传递的确切值。 遗憾的是,您不能将要用作值的变量的名称编码,并插入实际值。 所以你的代码应该是这样的: // I am assuming you're getting your fprogram and cperiod values from controls. The // control names are of course u ... -
另一种可能的解决方案是创建一组报告。 第一份报告有一份大陆清单,其中包含下一份报告的链接,该报告有一份国家清单。 它有一个过滤器,它接受来自第一个(父)报告的参数,该报告是大陆的列表。 然后,第二个报告有另一个指向最终报告的链接,该报告接受前两个父报告的参数。 我之前在几个地方看过这种技术。 它基于钻取报告,请参阅此处以获取有关钻取报告的更多信息 。 它不如自定义网页好,但不是每个人都有友好的网站开发人员可用:-) Another possible solution is to create set of ...
-
SSRS通过报告参数(SSRS passing Report Parameters)[2022-10-07]
检查您的“报告参数”是否与您的数据集关联为“数据集参数”: Check that your "report parameters" have been associated with your dataset as "dataset parameters": -
SSRS通过多值参数在附加窗口中打开报告(SSRS passing multi-value parameters to open report in additional window)[2023-07-08]
部分问题是您多次传入多值参数。 例如,表达式的一部分会导致: ...&SOURCE=A&SOURCE=B&SOURCE=C... 您只能在网址中为每个参数设置一个值。 所以解决这个问题的办法是用逗号分隔这些值并将它们作为单个字符串传入。 然后,在子报表中,您需要再次解析它们。 "&SOURCE=" & join(Parameters!SOURCE.Value,",") 您可能会遇到其他问题,例如URL长度限制,但这会解决当前的问题。 Part of the problem is that you are ... -
只需添加其他查询字符串参数。 例如,传递参数 Date: 2009-06-01 MachineID: Machine1, Machine2, Machine3, Machine4 在名为server上名为Folder\MyReport的报告中,您可以使用以下URL: http://server/reportserver?%2fFolder%2fMyReport&rs:Command=Render&Date=2009-06-01&MachineId=Machine1&MachineId=Mac ...
-
SSRS 2008 - 来自多值参数的每个值的子报告(SSRS 2008 - Subreport for each value from multi-valued parameter)[2023-06-06]
要执行此操作,您必须将子报表放入列表或Tablix中。 据我所知,没有简单的方法让列表或tablix迭代多值参数中的值。 它只接受数据集。 因此,我能想到的唯一解决方法是将参数拆分为数据集中的一组行,这可能但不是微不足道的SQL。 但是,如果参数的可用值来自数据集,则情况会改善:您可以将Tablix / list挂钩到数据集,并过滤未在参数中选择的项目。 编辑:通过将数据集查询构建为表达式,我发现了将多值参数扩展为数据集的一种稍微有点破解的解决方案。 假设参数@MultiParamX此表达式将创建一个查询, ... -
有趣的问题,我唯一能想到的是将参数数组转换为数据集中的xml,然后通过xml节点将其转换为表。 然后应该在表达式中将数据集参数(让我们称之为@par)设置为: = "
" + join(Parameters!P.Value," ") + " " 然后查询数据集将是这样的: declare @parxml xml = @par Select p.query('./text()') from @parxml.nodes('/n') as T(p) 这将提供一个表,每个选定的参数值都有一 ...