Creating serializable objects from client, executing on host

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I am trying to create a system that will execute a method (in the
host environment) on an object passed to it via remoting. The object
should be created on the client side, passed MBV style to the host
where the host will execute the function defined in the interface. The
code below probably shows what I'm trying to do much better. As you
can imagine, it doesn't work; the exception thrown is shown under the
offending line of the client code.
Two questions:
1) How can I pass the objects that implement ICommandExecutable to the
host by value so that they run in the host's App Domain?
2) Is there a better way of accomplishing what I'm trying to do? Some
requirements of the problem are:
-- There could potentially be hundred's of "hosts" with the "client"
creating and pushing out commands for each of them to execute.
-- The commands may change frequently so the hosts can't know the
details of all possible commands and I cannot update or change the
host's code each time I add, edit, or remove executable commands.
Editing and changing the client is acceptable.

Any help would be greatly appreciated.
Thanks


=============================================================
=============================================================
RemoteCommand Library:

Public Class Executioner
Inherits MarshalByRefObject

Public Sub New()

End Sub

Public Function execute(ByVal command As ICommandExecutable) As
String
Return command.run()
End Function

End Class

'''''''''''''''''''''''''''''''''''

Public Interface ICommandExecutable

Function run() As String

End Interface


=============================================================
=============================================================
The Host (Module and app.config)

Imports System.Runtime.Remoting

Module Module1

Sub Main()

RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
False)
Console.Write("Press <enter> to exit")
Console.Read()
End Sub

End Module

'''''''''''''''''''''''''''''''''''''

<?xml version="1.0" encoding="utf-8" ?>
<configuration>


<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall"
objectUri="Executioner.rem"
type="RemoteCommand.Executioner, RemoteCommand" />
</service>
<channels>
<channel ref="tcp" port="49341" />
</channels>
</application>
</system.runtime.remoting>
....


=============================================================
=============================================================
The Client (Client code, app.config, ThreadGetter Class)

(...)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
False)
End Sub

Private Sub btnRemoteThread_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnRemoteThread.Click
Dim ralf As New RemoteCommand.Executioner
txtRemoteThread.Text = ralf.execute(New ThreadGetter())
//**
Unable to find assembly 'myClient, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'
**//
End Sub
(...)


'''''''''''''''''''''''''''''''''''''

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown mode="SingleCall"
type="RemoteCommand.Executioner, RemoteCommand"
url="tcp://localhost:49341/Executioner.rem" />
</client>
</application>
</system.runtime.remoting>

'''''''''''''''''''''''''''''''''''''

<Serializable()> _
Public Class ThreadGetter
Implements RemoteCommand.ICommandExecutable

Public Function run() As String Implements
RemoteCommand.ICommandExecutable.run
Return CStr(Threading.Thread.CurrentThread.ManagedThreadId)
End Function

End Class

.



Relevant Pages

  • Job management / systems monitoring
    ... I have a client who wishes to run a system that can do the following on ... The system should run on a central server, preferrably a unix host. ... The relevant batch jobs are situated on the local host, ... It must be possible to execute a main job which then starts several ...
    (comp.unix.admin)
  • Re: MessengerAPI in ASP.NET
    ... All this code would execute on the server. ... Not on the client. ... > Private Sub Page_Init(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Threading newbie problem: How do I join once a thread is done?
    ... thread, i.e. the client thread, the client will be blocked. ... will not be execute, because the client thread will be blocked on the the ... Public Sub ThreadProc() ... So we usually use the Thread.Join to wait the Client to exit, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problem using table_info and column_info with DBD::Proxy
    ... sub connected; ... Can't call method "execute" without a package or object ... # the client to execute method DBI::st, ...
    (perl.dbi.users)
  • Re: problem using table_info and column_info with DBD::Proxy
    ... sub connected; ... Can't call method "execute" without a package or object ... # the client to execute method DBI::st, ...
    (perl.dbi.users)