We help IT Professionals succeed at work.

Running in IDE or EXE in C# VS 2010

Kalpesh Chhatrala
on
How can We Find Code is executed from IDE or EXE ?

thanks
Comment
Watch Question

check task manager .. if the process for your exe says

exename.vshost.exe (it is run from your IDE)

if it says just exename.exe (it is run directly using the exe)
Kalpesh ChhatralaSoftware Consultant

Author

Commented:
but i wan to check inside from application not from task manager.
get the list of all running process using this:
http://www.howtogeek.com/howto/programming/get-a-list-of-running-processes-in-c/

and check for exename.vshost.exe in the list.
Kalpesh ChhatralaSoftware Consultant

Author

Commented:
but how can i match myapplcation exe with process list.

or is any another way ?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
or just check debugger.isattached
The way most people do it is with the following property:
// Sample for the Environment.UserInteractive property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
    Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);
    }
}
/*
This example produces the following results:

UserInteractive: True
*/

Open in new window

Kalpesh ChhatralaSoftware Consultant

Author

Commented:
Thanks