运行 远程机器上的代码
Run code on remote machine
在Java中,使用RMI API,您可以通过将代码发送到远程机器来执行来执行任意代码。我知道在 .NET 中使用 Remoting 或 WCF 可以实现类似但不完全相同的东西。
但根据我的经验,两者都不允许任意代码执行,远程机器仍然需要对该对象的引用,而不仅仅是一个接口。对吗?
我已经通过在更新的共享位置访问 DLL 来解决这个问题,并且远程计算机能够使用它来执行代码。有没有更好的方法?
编辑:
http://www.cs.ucsb.edu/~cappello/lectures/rmi/helloworld.shtml
在link中,方法调用只是returns一个字符串。然而,这可以是任何东西,并且客户事先不了解该方法的实现。
neither allows arbitrary code execution
没错,您必须公开要远程执行的代码。
...the remote machine still needs a reference to the object, not just an interface. Is that correct?
您不能在 WCF 客户端中add a reference to the service创建服务使用的 类 的本地副本。
not recommended for new development.
但是您可以通过从客户端和服务器项目添加对共享 dll 的引用来避免共享位置 dll,然后将相同的 dll 部署到两个位置。
或 add class source file as link 从一个项目到另一个项目。
运行 从字符串编译的任意代码
您可以在 运行 时编译和 运行 任意代码,并将其与一个简单的 WFC 方法结合使用,该方法接受一个字符串,编译并 运行 它,这将实现什么你想要:
- http://simeonpilgrim.com/blog/2007/12/04/compiling-and-running-code-at-runtime/
- Is it possible to dynamically compile and execute C# code fragments?
在Java中,使用RMI API,您可以通过将代码发送到远程机器来执行来执行任意代码。我知道在 .NET 中使用 Remoting 或 WCF 可以实现类似但不完全相同的东西。
但根据我的经验,两者都不允许任意代码执行,远程机器仍然需要对该对象的引用,而不仅仅是一个接口。对吗?
我已经通过在更新的共享位置访问 DLL 来解决这个问题,并且远程计算机能够使用它来执行代码。有没有更好的方法?
编辑: http://www.cs.ucsb.edu/~cappello/lectures/rmi/helloworld.shtml 在link中,方法调用只是returns一个字符串。然而,这可以是任何东西,并且客户事先不了解该方法的实现。
neither allows arbitrary code execution
没错,您必须公开要远程执行的代码。
...the remote machine still needs a reference to the object, not just an interface. Is that correct?
您不能在 WCF 客户端中add a reference to the service创建服务使用的 类 的本地副本。
not recommended for new development.
但是您可以通过从客户端和服务器项目添加对共享 dll 的引用来避免共享位置 dll,然后将相同的 dll 部署到两个位置。
或 add class source file as link 从一个项目到另一个项目。
运行 从字符串编译的任意代码
您可以在 运行 时编译和 运行 任意代码,并将其与一个简单的 WFC 方法结合使用,该方法接受一个字符串,编译并 运行 它,这将实现什么你想要:
- http://simeonpilgrim.com/blog/2007/12/04/compiling-and-running-code-at-runtime/
- Is it possible to dynamically compile and execute C# code fragments?