Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Experts,

I've a wpf application and a RPC appliation (Application Name MyRemoteApp and it is developed in C# using mod mono) running in Linux system.

I want to check in my wpf application if thre Remote Procedure call application is running or not.

Below is my code.


C#
public static bool CheckIfRemoteAppIsRunning()
        {
            bool bRetVal = false;
            string remoteSystem = "10.221.55.127";
            string procSearch = "MyRemoteApp";

            Process[] proc = System.Diagnostics.Process.GetProcessesByName(procSearch, remoteSystem);

            if (proc.Length > 0)
            {
                bRetVal = true;
                Console.WriteLine("Able to find: " + proc[0]);
            }
            else
            {
                Console.WriteLine("Unable to find: " + procSearch);
            }

            return bRetVal;
        }


But its throwing exception "Couldn't connect to remote machine.".

Please let me know whats the wrong in the code.

Regards,
Vidi
Posted

1 solution

Hello,

If you look at MSDN documentation for Process class you will realize that the GetProcessByName is supported for following platforms only.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
For Unix/Linux you can use SSH and then use
BAT
ps -Af | grep "YOUR PROCESS NAME"
The output returned by this command is easily. The typical output is shown below.
UID        PID  PPID  C STIME TTY          TIME CMD
hope     29197 18961  0 Sep27 ?        00:00:06 sshd: hope@pts/87
hope     32097 29197  0 Sep27 pts/87   00:00:00 -csh
hope     7209  32097  0 12:17 pts/87   00:00:00 ps -Af
mysql    18617 18581  0 Jan10 ?        05:36:19 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=my

You can use SharpSSH[^] library for this purpose.

Regards,
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900