Results 1 to 3 of 3

Thread: [2.0] Detecting if running in the IDE?

  1. #1

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    [2.0] Detecting if running in the IDE?

    Hi all!

    Does anyone know if its possible to detect if a C# program is running from the IDE and if so can anyone explain how it can be done?

    Cheers,

    Ryan Jones
    My Blog.

    Ryan Jones.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Detecting if running in the IDE?

    You would use preprocessor directives.
    Code:
    #if DEBUG
                MessageBox.Show("Debugging"); // This line will be compiled into a Debug build.
    #else
                MessageBox.Show("Release"); // This line will be compiled into a Release build.
    #endif
    The DEBUG symbol is defined for a Debug build but by default it is not for a Release build. Note that the conditioon is not tested at run time. It is tested at compile time and only a section that evaluates to true will be compiled into the assembly. For more information see the link below.

    http://msdn2.microsoft.com/en-us/library/4y6tbswk.aspx
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: [2.0] Detecting if running in the IDE?

    Ah great, that should work perfectly for what I need - thanks for the help!

    Cheers,

    Ryan Jones
    My Blog.

    Ryan Jones.

Posting Permissions

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



Click Here to Expand Forum to Full Width