从一个进程传递到另一个对象 [英] pass object from one process to another

查看:184
本文介绍了从一个进程传递到另一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个.NET托管程序。第一个是主应用程序,以及所述一个是一个独立的工具

I have two .NET managed assemblies. The first one is main application, and the one is an independent tool.

现在我要做的就是整合与主应用程序的小工具。因此,当用户点击从主应用程序中的按钮,在用户定义的对象需要传递给另一个小工具,这将运行到另一个不同的独立进程。

Now what I have to do is integrate the small tool with main application. So when user click on a button from main application the "User defined object" need to be passed to another small tool which will run into another different independent process.

但是,我们只能发送一个字符串参数只是一个过程。

But we can send only a single string argument only to a process.

有什么可以做到这一点最好的方法?我需要发送到另一个过程是为每个文件中的设置文件列表。这里设置为我的用户定义的对象。

What can be best approach to do this? What I need to send to another process is list of files with the settings for each file. Here setting is my "User defined object".

我还有一个扭曲了这一点。

I have another twist to this.

如果您进程不运行,我会送参数,它和运行过程中的第一次。 但是,如果进程正在运行,可我送参数,它与数据附加到现有一个没有从头重新启动它。

First time if you process is not running I will send parameter to it and run the process. But if process is running, can I send parameter to it and append the data to existing one without restarting it again from scratch.

任何有关的帮助。如何可以做到这一点。

Any help regarding that. How this can be done.

感谢

推荐答案

我发现了两个很好的解决上述问题。

I found two good solutions to the above question.

1)构造与所有给定输入作为列数据表,并编写为XML。并启动一个进程,该文件作为输入和读取XML文件到被调用的过程。 在这个解决方案,我已经在我的新工艺没有控制,我甚至无法调试。我发现很多的复杂性,而这样做。

1) Construct a datatable with all given input as column and write that as xml. And start a process with that file as input and read that xml file into the invoked process. In this solution, I have no control over my new process and I can’t even debug it. I found lot of complexity while doing this.

2),发现了这个解决方案,加上EXE作为参考的解决方案,只是用文件作为输入来组装简单的调用调用它。现在有它的总量控制。我甚至可以做的异常处理。

2) So found this solution, add the exe as a reference to solution and simply invoke it with file as input as simple call to an assembly. Now have total control on it. I can even do exception handling.

谢谢大家的回答。

这篇关于从一个进程传递到另一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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