[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: How to get this done?Any clue or examples?

Richard Bell

6/25/2004 4:40:00 PM

If you just want to remote one method in a trusted environment it's pretty
simple. You need to make the object in B remotable. i.e. derive from
MarshalByRefObject. You then need a proxy class to build into service A to
be able to call it. If you have only one method to remote, then it would be
easy to code this yourself. Depending on the methods signature something
like:-

namespace ServiceBNamespace{
public class ServiceBClass : MarshalByRefObject
{
public object ServiceBMethod(){
return null;
}
}
}

Build Service A with this code.You can then create a new ServiceBClass and
call ServiceBMethod(). You then need to add a remoting configuration files
to tell ServiceA where to create the ServiceBClass object and ServiceB what
classes it is remoting. You can configure remoting by calling
RemotingConfiguration.Configure (although apparently there may be a bug in
1.1 - see other posts) presumably in the service OnStart event. Something
like the following will do the trick

Cient\ServiceA
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="ServiceB.ServiceBClass, ServiceA"
url="tcp://servicebhost:1234/MyService/ServiceBClass.rem"/>
</client>
</application>
</system.runtime.remoting>
</configuration>

Server\ServiceB
<configuration>
<system.runtime.remoting>
<application name="MyService">
<channels>
<channel ref="tcp" port="1234"/>
</channels>
<service>
<wellknown mode="SingleCall"
type="ServiceB.ServiceBClass, ServiceB, Server"
objectUri="ServiceBClass.rem"/>
</service>
</application>
</system.runtime.remoting>
</configuration>

If you need trust, encryption or are worried about speed then you will need
to dig a bit further.

"Sachi" <Sachi@discussions.microsoft.com> wrote in message
news:1F8F3D23-B69A-428D-83F7-3EC043925761@microsoft.com...
> Hi,
> I am having two windows services A, B.
> At certain point I need to invoke a method in B from A.
> I could search in documentations and see that it could be possible.
> As I am not any expert in remoting, here I am looking for some experts
comments.
>
> Is there any example to show this kind of functionality?
>
> Thanks and Regards,
> Sachi