...

View Full Version : .NET Remoting Exception: The system cannot find the file specified



hkucsis
05-11-2004, 09:39 AM
Hi,

I am learning .NET remoting and following the tutorial

http://www.csharphelp.com/archives2/archive460.html

Everything works fine.

Now I want to modify it a bit for my personal use but I failed :o

Original file



using System;
using System.Runtime.Remoting.Lifetime;

namespace Remote.Samples
{
public class MyRemoteObject:System.MarshalByRefObject
{
public MyRemoteObject()
{
Console.WriteLine("MyRemoteObject Constructor Called");
}
public override object InitializeLifetimeService()
{
return null;
}
public string Hello()
{
return "Hello, Welcome to .Net Remoting !";
}
}
}


I want to modify the Hello method so that it will execute the command I want



public string Hello()
{
ps = new System.Diagnostics.ProcessStartInfo();
ps.FileName= @"C:\USERLIST.EXE"; //The command I want to execute, I am sure the file is there
ps.RedirectStandardOutput=true;
p = new System.Diagnostics.Process();
ps.UseShellExecute=false;
p.StartInfo=ps;
p.Start(); // this causes Exception
return p.StandardOutput.ReadToEnd();
}


Output
Exception: The system cannot find the file specified
How to solve the problem?

Million thanks.

Michael

Roy Sinclair
05-11-2004, 02:42 PM
Is "USERLIST.EXE" in the root of the C: drive? If not, then the command won't execute because it can't find the file (which would explain the error message).

hkucsis
05-12-2004, 03:30 AM
Is "USERLIST.EXE" in the root of the C: drive? If not, then the command won't execute because it can't find the file (which would explain the error message).

Thanks for your reply.

I am sure USERLIST.EXE is in the root of C drive.

Roy Sinclair
05-12-2004, 02:48 PM
What line is running when you get the error?

hkucsis
05-13-2004, 04:04 AM
What line is running when you get the error?

p.Start(); // this causes Exception

The modified Hello() method works in localhost, but not with real IP (The case I run the server and the client in two different machines).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum