472,982 Members | 2,237 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

.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 6237
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Karuppasamy | last post by:
H I have created a Windows Application using C#. This Windows application makes a call to a Remoting Object which runs as a Windows Service. This Remoting Component makes a call to a Com+(Name :...
2
by: MS | last post by:
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...
0
by: Maurice | last post by:
Our product is build using the .NET framework 1.1. We have WinForm application that communicates a server via Remoting (tcp channel). We have two ways communication: From application to...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
0
by: Data | last post by:
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...
3
by: Ryan H | last post by:
Hi, My data access layer for my VB.NET 1.1 application resides on a different server and is accessed via Remoting. Is there a way to configure my data access layer so that I can use...
1
by: Derrick | last post by:
Hello all; I'm having a bit of trouble with .NET remoting. Here's my scenario: I have a "remotable" type which is served by a Windows Service. I have a WinForms app which consumes the...
2
by: Wimpie van Lingen | last post by:
Hey I have some more questions with regards to Remoting in .NET 2. I'm using TCP with the Binary formatter. My solution consists of 4 projects: - Class Library containing the server classes...
3
by: Adhal | last post by:
Hi, I am using remoting to pass in parameters from new launches of an application. So basically I have only one instance of the application and I am using remoting to pass the parameters. ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.