C#:让我的程序调用同一台机器上正在运行的进程的方法
我正在编写一个 C# 工具,它将对其他程序进行依赖性检查。我这样做的一种方法是迭代进程数组并查看是否找到某个进程名称。如果是这样,我想在进程上调用某个方法(我知道它支持)。该方法返回一个字典。我想获取该字典输出并在我的依赖项检查器中使用它。
所有这一切都发生在同一个工作站上,而不是通过网络。
我该怎么做?我的程序可以通信并调用进程上的方法并存储结果吗?我必须使用IPC吗? .NET 远程处理?如何??
我从未使用过这些工具。我想知道从哪里开始>
有人可以给我一些建议吗?
我使用的是.NET 2.0,所以我没有WCF。还有其他想法吗?
I'm writing a C# tool which will do dependency checks for other programs. One way I do that is I iterate through the process array and see if a certain process name is found. If so, I would like to call a certain method on the process (which I know it supports). That method returns a dictionary. I would like to take that dictionary output and use it in my dependency checker.
All this happens on the same workstation not across a network.
How can I do this? I can my program communicate and call a method on a process, store that result? Do I have to use IPC? .NET remoting? How??
I've never used any of those tools. I would like to know where to start>
Can someone give me some advice please?
I'm using .NET 2.0 so I donot have WCF. Any other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,某种形式的 .NET Remoting 实现可能是您选择的方法。当然,这确实要求您为这两个进程创建代码。
如果您无法控制其他进程,并且该进程没有用于进程间通信的记录接口,那么我认为您无法访问该进程中的方法。
Yes, some form of .NET Remoting implementation would probably be the method of choise for you. This does of course require that you are creating the code for both of the two processes.
If you are not in control of the other process and that process doesn't have a documented interface for interprocess communication, then I don't think you can access methods within that process.
您可以在 WCF 中使用命名管道来实现此目的:
http://www.switchonthecode .com/tutorials/wcf-tutorial-basic-interprocess-communication
本教程展示了一个简单的示例,我相信您正在尝试执行此操作。
You could use named pipes in WCF for this:
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
This tutorial shows a simple example of what I believe you are trying to do.