C#调用外部函数(类其他机器)
是否可以调用外部类上的函数? 外部类在另一台机器上运行(假设它的位置是 mymachine.com)。 前段时间使用过CreateInstance
,但我认为这行不通(如果我错了,请纠正我)。 我已经寻找了很长时间,但还没有找到解决方案,所以我希望你们中的一位能够提供帮助。
我搜索过的来源之一是但没有信息:( http://www.dreamincode。 net/forums/topic/102523-call-an-external-function-on-button-click/
希望你能提供帮助。
It it possible to call a function on an external class?
The external class runs on another machine (say its locations is mymachine.com).
have used CreateInstance
some time ago but don't think that will do (correct me if I'm wrong).
I have been searching for a long time but haven't found a solution yet so I hope one of you can help.
one of the sources i have searched is but no info :(
http://www.dreamincode.net/forums/topic/102523-call-an-external-function-on-button-click/
hope u can help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用自托管 WCF 服务、远程处理或任何网络技术。
不幸的是没有魔法属性可以实现这一点。
[编辑]我还想补充一点,你我要小心。当您使用某些远程处理机制(远程处理、WCF、rpc 等)时,您将使用“代理”。代理是模拟实际对象但封装通信的对象。它允许开发人员通过拥有具有属性、方法等的对象来隐藏复杂性,但开发人员必须了解背后的技术(例如 WCF 服务的 xml 消息传递)。它可能会对网络、响应能力以及编程模型产生影响。
use a self hosted WCF service, remoting or any networking technology.
There is unfortunately no magic attribute to achieve that.
[Edit] I also would like to add that you me be careful. When you are using some remoting mechanisms (either remoting, WCF, rpc, etc.) you work with "proxies". A proxy is an object that simulate the actual object, but encapsulate the communication. It allow the developer to hide the complexity by having an objects, with properties, methods etc., but the technologies behind (xml messaging for a WCF service for example) must be known by the developer. It can have impacts on network, responsiveness, and also programming model.
这种操作正是 Web 服务/WCF 服务/远程处理的目的。 WCF 是处理跨边界通信的非常好的解决方案。看看 WCF,google 是你的朋友。
This sort of operation is what Web Services / WCF Services / Remoting is built for. WCF is a really nice solution for handling communication across boundaries. Have a look into WCF, google is your friend.
看看这些:
http://www.aspfree .com/c/a/.NET/Windows 上的 RPC-I 简介/
http://www.csharphelp.com/2007/01/interprocess-communication/
See these:
http://www.aspfree.com/c/a/.NET/Introduction-to-RPC-on-Windows-Part-I/
http://www.csharphelp.com/2007/01/interprocess-communication/
如果外部程序集位于远程计算机上的共享文件夹上,则可以执行以下操作之一:
1) 实现 AppDomain.CurrentDomain.AssemblyResolve 事件处理程序来加载外部程序集,并使您需要拨打的电话。顺便还要在项目中添加对程序集的引用(copylocal = false)。对程序集中的类或静态方法实例的第一次调用将调用事件处理程序并加载远程外部程序集。
2) 使用 System.Reflection.Assembly.LoadFrom() 通过反射加载程序集并提供远程路径。使用反射来调用所需的方法等。
If the external assembly is on a shared folder on the remote machine, then you can do one of the following:
1) Implement the
AppDomain.CurrentDomain.AssemblyResolve
event handler to load the external assembly, and make the calls you need to make. Also put a reference to the assembly in your project by the way (copylocal=false). The first call to instance a class or static method in the assembly will invoke the event handler and load the remote external assembly.2) Load the assembly via reflection using
System.Reflection.Assembly.LoadFrom()
and provide te remote path. Use reflection to invoke the desired method, etc.