lysergic-acid
lysergic-acid

Reputation: 20050

Deploying and Executing code on a remote machine via Remoting/WCF

We're building a C# application that allows loading custom plugin DLLs and executing them.

Each DLL contains some task, and we'd like that task to be transparently executed either locally or on some remote server.

I have examined various solutions for this, and so far the best solution that was proposed was to use WCF.

I'd like to understand, since i'm currently only through basic tutorials of WCF, if it is at all possible to dynamically deploy new code using WCF to be executed remotely?

The way i see it, i have 2 different scenarios:

  1. Remote machine has a base "execution" library deployed.
  2. Remote machine has no WCF service installed on it currently.

With option #1, i guess i could have some functionality to send across the DLL or something, and execute it remotely, since the execution library knows how to do that already.

With option #2, i would need to basically deploy everything (somehow) from scratch, and then send a command to run it.

Is this scenario possible at all? do you have any tips to perform this kind of task?

Also, if you have any good WCF tutorials (i'm currently reading up on MSDN).

Thanks!

Upvotes: 2

Views: 1580

Answers (1)

Shtong
Shtong

Reputation: 1787

The important thing to remember here is that WCF can be used to transfer data, but not to tranfer execution logic. You can send the result of an addition from one end to the other, but you cannot send some arbitary instruction (like adding or whatever) and let the other end magically execute it.

In other words, if you have a WCF client on the remote end, you could send it your DLL file (as a binary data), and the client could then dynamically load and execute it using reflection (but what's without mentioning all the obvious security and compatibility concerns this would raise). Another maybe easier option would be to send scripts instead of compiled code, and execute them with some interpreter on the server side. But whatever trick you use, you'll need to do a lot of work outside of WCF as sending instructions is not the objective of WCF.

Upvotes: 3

Related Questions