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
  1. Home
  2. General Programming
  3. C#
  4. NullReferenceException

NullReferenceException

Scheduled Pinned Locked Moved C#
helpcomquestion
12 Posts 3 Posters 0 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.
  • G Offline
    G Offline
    greatM
    wrote on last edited by
    #1

    my program is working fine everywhere except one vista home premium client pc. there it shows "NullReferenceException : object reference not set to ..................." if any one can give some clue where could be the problem or any information if required from me? the relevant code is below: cLock = new ClsHasp(); bLock = cLock.gfCheckLock(); cLock is class variable of my FrmMain and is an object of class ClsHasp, and contains a function public bool gfCheckLock(), bLock is obviously bool type. error is in second line only 1 of several client pcs. thanking you in anticipation.

    manoj sharma 09313603665 manoj.great@yahoo.com

    V D 2 Replies Last reply
    0
    • G greatM

      my program is working fine everywhere except one vista home premium client pc. there it shows "NullReferenceException : object reference not set to ..................." if any one can give some clue where could be the problem or any information if required from me? the relevant code is below: cLock = new ClsHasp(); bLock = cLock.gfCheckLock(); cLock is class variable of my FrmMain and is an object of class ClsHasp, and contains a function public bool gfCheckLock(), bLock is obviously bool type. error is in second line only 1 of several client pcs. thanking you in anticipation.

      manoj sharma 09313603665 manoj.great@yahoo.com

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      Check the method gfCheckLock() there might be a variable/object in there that gives the error. Or it might just be in the constructor of the ClsHasp if there are objects/variables creates/initialized in there. good luck.

      V. If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)

      G 1 Reply Last reply
      0
      • G greatM

        my program is working fine everywhere except one vista home premium client pc. there it shows "NullReferenceException : object reference not set to ..................." if any one can give some clue where could be the problem or any information if required from me? the relevant code is below: cLock = new ClsHasp(); bLock = cLock.gfCheckLock(); cLock is class variable of my FrmMain and is an object of class ClsHasp, and contains a function public bool gfCheckLock(), bLock is obviously bool type. error is in second line only 1 of several client pcs. thanking you in anticipation.

        manoj sharma 09313603665 manoj.great@yahoo.com

        D Offline
        D Offline
        Dave Sexton
        wrote on last edited by
        #3

        What's happening in gfCheckLock()? If it's a null reference exception you're probably not instantiating something. Does the app call an external resource that the single client machine doesn't have perhaps? Are the other machines also running the same OS?

        But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson

        G 1 Reply Last reply
        0
        • V V 0

          Check the method gfCheckLock() there might be a variable/object in there that gives the error. Or it might just be in the constructor of the ClsHasp if there are objects/variables creates/initialized in there. good luck.

          V. If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)

          G Offline
          G Offline
          greatM
          wrote on last edited by
          #4

          class ClsHasp { private int seed; private int lptNum; private int passw1; private int passw2; public ClsHasp() { seed = 0; lptNum = 0; passw1 = 0; passw2 = 0; } public bool gfCheckLock() { try { System.Windows.Forms.MessageBox.Show("1"); =============== i m trying above in gfCheckLock(), even before any statement i m displaying a message, then also the same exception?? any ideas??

          manoj sharma 09313603665 manoj.great@yahoo.com

          V 1 Reply Last reply
          0
          • D Dave Sexton

            What's happening in gfCheckLock()? If it's a null reference exception you're probably not instantiating something. Does the app call an external resource that the single client machine doesn't have perhaps? Are the other machines also running the same OS?

            But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson

            G Offline
            G Offline
            greatM
            wrote on last edited by
            #5

            class ClsHasp { private int seed; private int lptNum; private int passw1; private int passw2; public ClsHasp() { seed = 0; lptNum = 0; passw1 = 0; passw2 = 0; } public bool gfCheckLock() { try { System.Windows.Forms.MessageBox.Show("1"); =============== i m trying above in gfCheckLock(), even before any statement i m displaying a message, then also the same exception?? any ideas?? as for the OS develop machine is win2k3, clients are xp as well as vista.

            manoj sharma 09313603665 manoj.great@yahoo.com

            1 Reply Last reply
            0
            • G greatM

              class ClsHasp { private int seed; private int lptNum; private int passw1; private int passw2; public ClsHasp() { seed = 0; lptNum = 0; passw1 = 0; passw2 = 0; } public bool gfCheckLock() { try { System.Windows.Forms.MessageBox.Show("1"); =============== i m trying above in gfCheckLock(), even before any statement i m displaying a message, then also the same exception?? any ideas??

              manoj sharma 09313603665 manoj.great@yahoo.com

              V Offline
              V Offline
              V 0
              wrote on last edited by
              #6

              Could be, not so long ago I had the same problem and tried to debug with messageboxes, they never showed either, but still the code was further down the line, so yes. Comment out all lines in gfCheckLock and do a return true.

              V. No hurries, no worries

              G 1 Reply Last reply
              0
              • V V 0

                Could be, not so long ago I had the same problem and tried to debug with messageboxes, they never showed either, but still the code was further down the line, so yes. Comment out all lines in gfCheckLock and do a return true.

                V. No hurries, no worries

                G Offline
                G Offline
                greatM
                wrote on last edited by
                #7

                thanx. i tried the same. this time its working(how?) but need to do the stuff inside.

                manoj sharma 09313603665 manoj.great@yahoo.com

                V 1 Reply Last reply
                0
                • G greatM

                  thanx. i tried the same. this time its working(how?) but need to do the stuff inside.

                  manoj sharma 09313603665 manoj.great@yahoo.com

                  V Offline
                  V Offline
                  V 0
                  wrote on last edited by
                  #8

                  So check the code that you replaced, the bug is in there somewhere.

                  V.
                  Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                  G 1 Reply Last reply
                  0
                  • V V 0

                    So check the code that you replaced, the bug is in there somewhere.

                    V.
                    Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                    G Offline
                    G Offline
                    greatM
                    wrote on last edited by
                    #9

                    as u can see above very first line of message doesn't get displayed. so what could b wrong?

                    manoj sharma 09313603665 manoj.great@yahoo.com

                    V 1 Reply Last reply
                    0
                    • G greatM

                      as u can see above very first line of message doesn't get displayed. so what could b wrong?

                      manoj sharma 09313603665 manoj.great@yahoo.com

                      V Offline
                      V Offline
                      V 0
                      wrote on last edited by
                      #10

                      How the hell should I know? Somewhere in the code you just replaced some variable or object hasn't been initialized... If you want help, please be more specific, I can't tell what you're doing if you don't elaborate on it more. I didn't develop that piece of code you know. I suggest you try to do some debugging or something.

                      V.
                      Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                      G 1 Reply Last reply
                      0
                      • V V 0

                        How the hell should I know? Somewhere in the code you just replaced some variable or object hasn't been initialized... If you want help, please be more specific, I can't tell what you're doing if you don't elaborate on it more. I didn't develop that piece of code you know. I suggest you try to do some debugging or something.

                        V.
                        Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                        G Offline
                        G Offline
                        greatM
                        wrote on last edited by
                        #11

                        please dont don't get it wrong? code is not giving problem everywhere?? it is running fine everywhere else. but on 1 pc only this is the error. so i guess it's not related to code but something other than that. that's why i need experts viewes. to start debugging on that client machine (i cant use debugger as no source code is there no vs2k5 is there) i m creating exe here, sending it client and then i came to know the results. that's why i m giving message. return true suggested by you works, but instead first line of messagebox doesn't come up only that single machine. hope this cools you down. any ideas??

                        manoj sharma 09313603665 manoj.great@yahoo.com

                        V 1 Reply Last reply
                        0
                        • G greatM

                          please dont don't get it wrong? code is not giving problem everywhere?? it is running fine everywhere else. but on 1 pc only this is the error. so i guess it's not related to code but something other than that. that's why i need experts viewes. to start debugging on that client machine (i cant use debugger as no source code is there no vs2k5 is there) i m creating exe here, sending it client and then i came to know the results. that's why i m giving message. return true suggested by you works, but instead first line of messagebox doesn't come up only that single machine. hope this cools you down. any ideas??

                          manoj sharma 09313603665 manoj.great@yahoo.com

                          V Offline
                          V Offline
                          V 0
                          wrote on last edited by
                          #12

                          Dude, It's not a question of cooling down or not, I can't help you without information. What's the contents of that specific function? It could be that it's machine related, like an unregistered dll, a setting, a missing file, etc, but it could be code. Can you write to a log file? Put some lines in the function and see what it does. You could also try to add beeps if all else fails.

                          V.
                          Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                          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