/// <summary> /// Initializes a new instance of the <see cref="RemoteClient"/> class. /// </summary> public RemoteClient() { clientchannel = new IpcChannel(); ChannelServices.RegisterChannel(clientchannel, false); RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject), "ipc://localhost:15000/RemoteObject.rem"); RemoteObj = new RemoteObject(); sponser = new RemoteClientSponser("RemoteClient"); lease = (ILease)RemoteObj.GetLifetimeService(); lease.Register(sponser); }
/// <summary> /// Loads the user code. /// </summary> /// <param name="AssemblyPath">The assembly path.</param> private static void Load() { if (!File.Exists(AssemblyPath)) throw new FileNotFoundException("The assembly cannot be found.", AssemblyPath); MarshalByRefObject obj; ad = AppDomain.CreateDomain("Sandbox", null, ads); obj = (MarshalByRefObject)ad.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "ScriptKeyCode.RemoteLoader"); target = (IScript)obj; try { lease = (ILease)obj.GetLifetimeService(); sponser = new RemoteClientSponser("CodeHost"); lease.Register(sponser); target.Load(AssemblyPath); } catch (Exception ex) { OnErrorOccured(ex); } }