473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 6264
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. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.