Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. C# code works fine in debug mode but not while running

C# code works fine in debug mode but not while running

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdebugginghelp
8 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    netEnthu
    wrote on last edited by
    #1

    Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

    C S L C N 5 Replies Last reply
    0
    • N netEnthu

      Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      .netEnthu wrote:

      I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated.

      I presume by "run mode" what you really mean is "Release"? Or are you taking the debug build and running it outside of Visual Studio? Also, it helps if you post the snippet so we can see what is going on. Saying it "doesn't work" is somewhat vague and unhelpful.


      Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

      1 Reply Last reply
      0
      • N netEnthu

        Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

        S Offline
        S Offline
        subrata jana
        wrote on last edited by
        #3

        In Debug some values will be set to default values while in realse it may be assigned with null. Code depending on those may give some error also. Pls check for #if Debug kind of directives in this case the could will only work in debug mode never in release mode

        C 1 Reply Last reply
        0
        • S subrata jana

          In Debug some values will be set to default values while in realse it may be assigned with null. Code depending on those may give some error also. Pls check for #if Debug kind of directives in this case the could will only work in debug mode never in release mode

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          subrata.jana wrote:

          In Debug some values will be set to default values while in realse it may be assigned with null.

          No it won't. An integer will be assigned 0 by default in Debug and Release. A Boolean will be false in both. A reference type will be null by default in both debug and release. Can you cite any example where an object is assigned one value by default in a Debug build and another in Release?


          Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            subrata.jana wrote:

            In Debug some values will be set to default values while in realse it may be assigned with null.

            No it won't. An integer will be assigned 0 by default in Debug and Release. A Boolean will be false in both. A reference type will be null by default in both debug and release. Can you cite any example where an object is assigned one value by default in a Debug build and another in Release?


            Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

            S Offline
            S Offline
            subrata jana
            wrote on last edited by
            #5

            Thanks to correct me. Then only we can check for #if Debug .in this case.

            1 Reply Last reply
            0
            • N netEnthu

              Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              .netEnthu wrote:

              the same code doesn't work

              Dont hesitate to be a little bit more specific, so we might be able to help.

              .netEnthu wrote:

              a C# code snippet

              care to share it ? :)

              Luc Pattyn [My Articles]

              1 Reply Last reply
              0
              • N netEnthu

                Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Do you have any threads running ? Are the bugs UI related ? I often find that breakpoints can make code work, because it will force a break which causes things to work where otherwise they face a race condition, or where a paint message gets lost due to too much processing happening for it to occur, that sort of thing. What is the nature of the bug ?

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                1 Reply Last reply
                0
                • N netEnthu

                  Hi, I have a C# code snippet using thread and delegates which works fine in debug mode i.e. with break points and the same code doesn't work in run mode. I am running this on Windows XP 64 bit OS and .net 2.0. Any help in this regard is appreciated. AZ

                  N Offline
                  N Offline
                  Nouman Bhatti
                  wrote on last edited by
                  #8

                  may be one of your threads working depends on other thread .. and at runtime a deadlock creates due to lesser time or some other reason.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups