469,925 Members | 1,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

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

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 );
}
Nov 16 '05 #1
5 6047
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" wrote:
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 );
}

Nov 16 '05 #2
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" <Ma*********@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
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" wrote:
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 );
}

Nov 16 '05 #3
Hi,

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

Sunny

In article <uo*************@TK2MSFTNGP12.phx.gbl>,
go***********@yahoo.com says...
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" <Ma*********@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
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" wrote:
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 );
}


Nov 16 '05 #4
"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" wrote:
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" <Ma*********@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
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" wrote:
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 );
}


Nov 16 '05 #5
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" <Ma*********@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
"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" wrote:
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" <Ma*********@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
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" wrote:

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


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Karuppasamy | last post: by
2 posts views Thread by MS | last post: by
reply views Thread by Maurice | last post: by
3 posts views Thread by Ryan H | last post: by
1 post views Thread by Derrick | last post: by
2 posts views Thread by Wimpie van Lingen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.