.Net Remoting problem: No connection could be made because the target machine

D

Data

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 );
}
 
G

Guest

Are you configurating the executable before you launch it?

I don't know anything about WMI, but I've used remoting a fair bit. As you say, if the server isn't running, then you get the error message. Are you trying to start up and shut down a remoting exe at will, or just run it?


Martin.
 
D

Data

Hi

I want to start and stop the exe at will. When I start the exe manually
everything works fine. If I executed it through code using WMI I get this
error. R there any other ways other than WMI to execute an exe on the
remoted machine?

Thanks

Martin Platt said:
Are you configurating the executable before you launch it?

I don't know anything about WMI, but I've used remoting a fair bit. As
you say, if the server isn't running, then you get the error message. Are
you trying to start up and shut down a remoting exe at will, or just run it?
Martin.

Data said:
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 );
}
 
S

Sunny

Hi,

why you not host your server in windows service, and remotely start/stop
the service?

Sunny

Hi

I want to start and stop the exe at will. When I start the exe manually
everything works fine. If I executed it through code using WMI I get this
error. R there any other ways other than WMI to execute an exe on the
remoted machine?

Thanks

Martin Platt said:
Are you configurating the executable before you launch it?

I don't know anything about WMI, but I've used remoting a fair bit. As
you say, if the server isn't running, then you get the error message. Are
you trying to start up and shut down a remoting exe at will, or just run it?
Martin.

Data said:
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 );
}
 
G

Guest

"Data"

I agree with what sunny is saying - see parallel posting.
I think by choosing the implementation you are, you're making it hard for yourself.
If you're remoting, and you have the two servers in there, you can also set properties in your executable as it is at the moment, so that it appears to unload, or actually to unload it.

I think you need to consider your design decisions, and question whether there are better, more dependable ways to achieve what you want to achieve....

By all means reveal there what where and why of your design, and we can try to help you?

Cheers,

Martin.

Data said:
Hi

I want to start and stop the exe at will. When I start the exe manually
everything works fine. If I executed it through code using WMI I get this
error. R there any other ways other than WMI to execute an exe on the
remoted machine?

Thanks

Martin Platt said:
Are you configurating the executable before you launch it?

I don't know anything about WMI, but I've used remoting a fair bit. As
you say, if the server isn't running, then you get the error message. Are
you trying to start up and shut down a remoting exe at will, or just run it?
Martin.

Data said:
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 );
}
 
D

Data

Hi Everyone
I found the bug in my code and the problem as been
fixed. Now I am facing new problem. My server is running fine but while
doing a certain task it throws following exception:

System.Security.SecurityException: Request for principal permission failed

what are the possible causes of the exception? and what r the resolutions?

Thanks for your help

Data

Martin Platt said:
"Data"

I agree with what sunny is saying - see parallel posting.
I think by choosing the implementation you are, you're making it hard for yourself.
If you're remoting, and you have the two servers in there, you can also
set properties in your executable as it is at the moment, so that it appears
to unload, or actually to unload it.
I think you need to consider your design decisions, and question whether
there are better, more dependable ways to achieve what you want to
achieve....
By all means reveal there what where and why of your design, and we can try to help you?

Cheers,

Martin.

Data said:
Hi

I want to start and stop the exe at will. When I start the exe manually
everything works fine. If I executed it through code using WMI I get this
error. R there any other ways other than WMI to execute an exe on the
remoted machine?

Thanks

Martin Platt said:
Are you configurating the executable before you launch it?

I don't know anything about WMI, but I've used remoting a fair bit.
As
you say, if the server isn't running, then you get the error message. Are
you trying to start up and shut down a remoting exe at will, or just run it?
Martin.

:

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 );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top