Results 1 to 5 of 5

Thread: [02/03] How to find whether we are in Dev environment

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    [02/03] How to find whether we are in Dev environment

    Hi,

    How to find whether we are working in development environment ?

    My requirement is the application I design has to save some data on some path if it is under development environment. if it is live environment then it has to save in live path.

    let me know

    thanks
    Kanna

  2. #2

  3. #3
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: [02/03] How to find whether we are in Dev environment

    You pass command arguments to ur app like this:

    "C:\WindowsApplication3.exe" "DEV"

    and get the arguments in ur app like this:

    vb.net Code:
    1. Private Sub Form1_Load( _
    2.     ByVal sender As System.Object, _
    3.     ByVal e As System.EventArgs _
    4. ) Handles MyBase.Load
    5.  
    6.     Dim str As String
    7.     Dim args() As String
    8.  
    9.     args = Environment.GetCommandLineArgs()
    10.     If args.Length > 0 Then
    11.         For Each str In args
    12.             MessageBox.Show(str)
    13.         Next
    14.     End If
    15. End Sub
    You can get the value of command line argument and do the stuff needed based on it.

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

    Re: [02/03] How to find whether we are in Dev environment

    Use conditional compilation:
    vb.net Code:
    1. #If DEBUG Then
    2.         'Code here will only be compiled into a Debug build.
    3. #Else
    4.         'Code here will only be compiled into a Release build.
    5. #End If
    Note that the # symbols are part of the code. This is not a regular VB If statement. It is a directive to the compiler. the decision is not made at run time but rather at compile time. Only one of the code blocks will get compiled depending on the build configuration and there will be no If statement at run time.
    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

  5. #5

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: [02/03] How to find whether we are in Dev environment

    Found solution myself.

    vb Code:
    1. Public Function IsApplicationRunningInIDE() As Boolean
    2.         IsApplicationRunningInIDE = System.Diagnostics.Debugger.IsAttached()
    3.     End Function
    This will return true if we work in IDE and will return false if it is exe.

    Thank you all for your help.
    Kanna

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