Is running in DEBUG or RELEASE MODE ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pod
    Contributor
    • Sep 2007
    • 298

    Is running in DEBUG or RELEASE MODE ?

    Hello

    I have several VB.NET Windows Form applications connecting tp several Network databases. When I build, update and test my apps, I want them to connect to a testing database as opposed to connecting to the production databases when the app is released.

    Right now, I change a setting in my coding before releasing the app, but I would like this to be automatic, to prevent any testing data in the Production database and vice versa.

    I found this piece of coding on the web, but it doesn't seem to ever be in DEBUG mode...
    and by DEBUG mode I mean when I click the "Start Debugging" button or the F5 key

    Code:
    #If DEBUG Then
        msgbox "DEBUG"
    #Else
            MsgBox("NOT DEBUG !")
    #End If


    Thank you for your input in advance



    P:oD
  • R MacDonald
    New Member
    • Mar 2011
    • 24

    #2
    Hello, P:od,

    In the IDE you can select either Debug mode or Release mode. (Actually, if the spirit moves you to do so, you can define other modes as well. But Debug and Release are provided by default.)

    Select the Project+Propert ies menu item and choose the "Compile" tab from the tabs on the left hand side of the display. Select "Debug" from the "Configurat ion" drop down at the top left. Then click on the "Advanced Compile Options..." button. In the form that appears, ensure that the "Define DEBUG constant" CheckBox is checked. After clicking the [OK] button, change the "Configurat ion" drop down to "Release" and repeat the procedure, this time ensuring that the "Define DEBUG constant" CheckBox is NOT checked.

    Your code example should then perform as expected. That is, when Debug configuration is specified, you should get the "DEBUG" MsgBox appearing when you start the application with the <F5> key. When Release configuration is specified, the "NOT DEBUG !" MsgBox will appear.

    Cheers,
    Randy
    Last edited by R MacDonald; Apr 15 '11, 12:03 AM. Reason: Extend the explanation.

    Comment

    • pod
      Contributor
      • Sep 2007
      • 298

      #3
      Hi Randy,

      I was hopeful to have found a solution with your suggestion, but found my settings already set as you proposed, in both configuration mode.

      I even updated my code to the following but to no avail.

      #If Debug = True Then ...

      Although, your suggestion was not a solution, it made me aware of these Configuration mode settings...Ther e are two other settings, ... obviously, I will have to read up on this.

      Maybe I am misunderstandin g this DEBUG vs RELEASE mode:
      am I right to presume that when I run the app from Visual Studio it is in DEBUG... and that when it is published and running from the Programs Files after installation, it is in RELEASE mode?

      When publishing my app for use, should I be setting the configuration to Release? or is it done automatically?



      Anything else you can offer is appreciated,

      Thanks for answering



      Perry :oD
      Last edited by pod; Apr 15 '11, 01:52 PM. Reason: politesse ethics

      Comment

      • R MacDonald
        New Member
        • Mar 2011
        • 24

        #4
        Hi, Perry,

        Re: "am I right to presume that..."

        No, that's not quite correct and so may be the source of the problem. You can run the code from the IDE in either DEBUG mode or RELEASE mode. And likewise, you can install and run either the DEBUG build or the RELEASE build outside of the IDE.

        Which mode is being used is most easily controlled by using the "Solution Configurations" DropDown on the "Standard" toolbar. If the Standard toolbar is not displayed, you can also adjust the mode by using the "Build+Configur ation Manager..." menu command. The latter will display a dialog that shows the defined configurations in a DropDown box in the upper left corner of the dialog. This dialog box also allows you to create new configurations (modes) or to rename/delete existing configurations. The specifications of the different configurations can be modified by using the "Compile" and "Debug" tabs on the Project Properties window.

        Hope that helps.

        Cheers,
        Randy

        Comment

        • R MacDonald
          New Member
          • Mar 2011
          • 24

          #5
          Hello again, Perry,

          Incidentally, I should have also mentioned that when you have multiple projects within your solution, you can define solution configurations which specify different project configurations. That is, I can create a new configuration (called "MyMode", for example). Then in the "Solution Properties" dialog, by selecting "Configurat ion Properties+Conf iguration" in the left hand panel, I could set MyMode to have Project1 in DEBUG mode and project2 in RELEASE mode.

          Cheers,
          Randy

          Comment

          • pod
            Contributor
            • Sep 2007
            • 298

            #6
            This was very informative. Using the drop-down will make the switching of database a little simpler.

            If only I could set the IDE to switch itself to Release mode or at least to alert me to do so before I publish...

            I'm not giving up yet, I'll do some more research

            Thank you very much Randy for all your help.
            Last edited by pod; Apr 18 '11, 11:50 AM. Reason: typo

            Comment

            Working...