Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2003
    Location
    Hong Kong
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

    Original file

    Code:
    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

    Code:
    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Mar 2003
    Location
    Hong Kong
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Roy Sinclair
    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.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What line is running when you get the error?
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    New Coder
    Join Date
    Mar 2003
    Location
    Hong Kong
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Roy Sinclair
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •