Help in remoting !

  • Thread starter Thread starter MS
  • Start date Start date
M

MS

In my project I want to execute some commands on the remote machine. I am
using .Net Remoting to achieve this. My server which is an exe is copied on
the remote machine and it receives command from client which is executed by
the exe. I am facing problem while executing the exe on the remote machine.
If I start the exe manually everything works fine but if I execute it
remotely through code using WMI an exception is thrown saying "No connection
could be made because the target machine actively refused it". This
exception is generally thrown when the remote server is not running but the
task manager of the remote machine shows that the exe is running. I am
using Win32_process class to do this. The MSDN help of Win32_process class
Create() method says "For security reasons the Win32_Process.Create method
cannot be used to start an interactive process". Is this the reason for the
exception? If so, then what is the alternative for executing an exe on
remote machine?



I am pasting the code snippet of my client and server below



Code of Server:



RemotingConfiguration.Configure( "rpcserver.exe.config" );

TcpServerChannel channel = new TcpServerChannel(rs.mPort);

ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(

typeof(RemoteServerObject),

"ToolCommand",

WellKnownObjectMode.SingleCall);





Code for Client:



ManagementScope obScope = new ManagementScope("\\\\" + remoteServer +
"\\root\\CIMV2");

ManagementClass shareClass = new ManagementClass( "\\\\" + remoteServer +
"\\root\\CIMV2:Win32_Process" );

object[] param = {"c:\\temp\\rpcserver.exe",null,null,null};

object response = shareClass.InvokeMethod( "Create", param );

}
 
The error you are getting sounds like your server app is an interactive
application. Is this true? (Doesn't make sense to me).

I'd assume that your server would be implemented as a windows service or
started by a windows service. Is this the case?

? confused ?
--- Nick
 
Hi,

can you put all channel and object registration code in try/catch block,
and make a logging in a local text file for every step performed and
possible exceptions?

Sunny
 
Back
Top