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. Creating object stops execution of entire function

Creating object stops execution of entire function

Scheduled Pinned Locked Moved C#
questioncomhelplounge
18 Posts 5 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.
  • N Nissim Salomon

    Hi did you try using a try / catch block in order to catch exception ???

    _ Offline
    _ Offline
    __DanC__
    wrote on last edited by
    #7

    I have a try...catch block inside the Init() function to catch the exception but the problem is that the execution does not enter the Init() functio if that line exists so therefore no exception is thrown.

    Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

    N 1 Reply Last reply
    0
    • _ __DanC__

      I have a try...catch block inside the Init() function to catch the exception but the problem is that the execution does not enter the Init() functio if that line exists so therefore no exception is thrown.

      Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

      N Offline
      N Offline
      Nissim Salomon
      wrote on last edited by
      #8

      use the try catch before the call to the init function

      _ 1 Reply Last reply
      0
      • N Nissim Salomon

        use the try catch before the call to the init function

        _ Offline
        _ Offline
        __DanC__
        wrote on last edited by
        #9

        I should have mentioned, I have also wrapped the Init() in a try...catch but again, nothing, no exception, nothing, just a hung application.

        Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

        N L 2 Replies Last reply
        0
        • _ __DanC__

          I should have mentioned, I have also wrapped the Init() in a try...catch but again, nothing, no exception, nothing, just a hung application.

          Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

          N Offline
          N Offline
          Nissim Salomon
          wrote on last edited by
          #10

          OK sorry Can you give more details about the MyObject class ???? and the environment that your application running ??? thanks

          _ 1 Reply Last reply
          0
          • N Nissim Salomon

            OK sorry Can you give more details about the MyObject class ???? and the environment that your application running ??? thanks

            _ Offline
            _ Offline
            __DanC__
            wrote on last edited by
            #11

            The environment is Visual Studio 2003, .NET 1.1, Windows XP. The MyObject class is a third-party assembly containing lots of system calls, I understand that the problem could well be within the assembly and not my code and therefore out of my reach to fix but I would like to understand how a problem in a DLL assembly could stop the debugger entering the calling function, I could understand if it hung on the constructor of the MyObject class but I cannot see how it could hang on the calling function.

            Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

            N H 2 Replies Last reply
            0
            • _ __DanC__

              I should have mentioned, I have also wrapped the Init() in a try...catch but again, nothing, no exception, nothing, just a hung application.

              Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

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

              OK, now what is MyObject class supposed to do ? any idea what would be inside its constructor ? have you other apps that use MyObject successfully ? :)

              Luc Pattyn [My Articles] [Forum Guidelines]

              _ 1 Reply Last reply
              0
              • L Luc Pattyn

                OK, now what is MyObject class supposed to do ? any idea what would be inside its constructor ? have you other apps that use MyObject successfully ? :)

                Luc Pattyn [My Articles] [Forum Guidelines]

                _ Offline
                _ Offline
                __DanC__
                wrote on last edited by
                #13

                The MyObject implements a set of delegates which attach to system events allowing them to be handled by a .NET 1.1 application which they would otherwise not be able to do. I have no idea what would be in the constructor unfortunately but on further testing I have found that a call to a static function within the class prodcues the same result so I am confident it is an issue with the assembly but that still doesn't get me any closer to why the entire function does not execute.

                Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

                L 1 Reply Last reply
                0
                • _ __DanC__

                  The environment is Visual Studio 2003, .NET 1.1, Windows XP. The MyObject class is a third-party assembly containing lots of system calls, I understand that the problem could well be within the assembly and not my code and therefore out of my reach to fix but I would like to understand how a problem in a DLL assembly could stop the debugger entering the calling function, I could understand if it hung on the constructor of the MyObject class but I cannot see how it could hang on the calling function.

                  Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

                  N Offline
                  N Offline
                  Nissim Salomon
                  wrote on last edited by
                  #14

                  I run into some problems with the debugger (crushes,hangs and so on) usually while doing some system programming, the solution to that in most cases was just restart. you can try one of the following: 1.try to debug on another machine (check that you don't have problem in your environment) 2.use the System.Diagnostics.Debugger.Break(); command in order to force break. 3 use the sos debug extension in order to examine the runtime steps at execution 4 restart your computer and try again

                  1 Reply Last reply
                  0
                  • _ __DanC__

                    The MyObject implements a set of delegates which attach to system events allowing them to be handled by a .NET 1.1 application which they would otherwise not be able to do. I have no idea what would be in the constructor unfortunately but on further testing I have found that a call to a static function within the class prodcues the same result so I am confident it is an issue with the assembly but that still doesn't get me any closer to why the entire function does not execute.

                    Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

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

                    OK, sounds like there is a problem with a static initializer in MyObject. I can see two ways forward now: - contact the author - try figuring out what is in the initializer using Reflector. I assume you are on .NET 2.0 or 3.x; you might want to try MyObject inside a .NET 1.1 project, just to see if it works for you; the simplest invocation of MyObject should be sufficient. BTW I am not impressed by a "third party" that calls its stuff "MyObject". Good luck !

                    Luc Pattyn [My Articles] [Forum Guidelines]

                    _ 1 Reply Last reply
                    0
                    • L Luc Pattyn

                      OK, sounds like there is a problem with a static initializer in MyObject. I can see two ways forward now: - contact the author - try figuring out what is in the initializer using Reflector. I assume you are on .NET 2.0 or 3.x; you might want to try MyObject inside a .NET 1.1 project, just to see if it works for you; the simplest invocation of MyObject should be sufficient. BTW I am not impressed by a "third party" that calls its stuff "MyObject". Good luck !

                      Luc Pattyn [My Articles] [Forum Guidelines]

                      _ Offline
                      _ Offline
                      __DanC__
                      wrote on last edited by
                      #16

                      It's not called MyObject, I just used that to demonstrate the problem ;) I would be equally unimpressed if it were :-D It is currently in .NET 1.1, the assembly and my project are both 1.1. I've contacted the author and waiting on a reply. The question I was asking more than what could be wrong with the assembly as I realise it is the assembly causing the problem is how that problem could cause my function not to be executed even before any calls are made to the assembly, I would expect it to fail at the point of referencing the assembly but at least execute the function calls above it.

                      Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

                      L 1 Reply Last reply
                      0
                      • _ __DanC__

                        It's not called MyObject, I just used that to demonstrate the problem ;) I would be equally unimpressed if it were :-D It is currently in .NET 1.1, the assembly and my project are both 1.1. I've contacted the author and waiting on a reply. The question I was asking more than what could be wrong with the assembly as I realise it is the assembly causing the problem is how that problem could cause my function not to be executed even before any calls are made to the assembly, I would expect it to fail at the point of referencing the assembly but at least execute the function calls above it.

                        Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

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

                        __DanC__ wrote:

                        I would expect it to fail at the point of referencing the assembly but at least execute the function calls above it.

                        I understand that is what would be expected, but when you reach the Init() method, the first thing that happens is the JIT compiles it; so it wonders about the MyObject class, it must locate it, and at some point in time, also statically initialize it. I am not sure exactly when that is supposed to happen; it must be deterministic of course, and I know the exact order is surprisingly complex; long time ago I suffered from a bug in that area, dont recall whether it was in 1.0 or 1.1 tho. I think it is safe to assume static constructors get executed at the start of the calling method (your Init), since the JIT in general must cope with a complex flow graph and multiple references to the class, so it cannot always (and hence does not even try to) predict which one will occur first, hence it will go for early initialization. You could proof this true or false by pushing the MyObject stuff and following code inside Init() one level deeper... :)

                        Luc Pattyn [My Articles] [Forum Guidelines]

                        1 Reply Last reply
                        0
                        • _ __DanC__

                          The environment is Visual Studio 2003, .NET 1.1, Windows XP. The MyObject class is a third-party assembly containing lots of system calls, I understand that the problem could well be within the assembly and not my code and therefore out of my reach to fix but I would like to understand how a problem in a DLL assembly could stop the debugger entering the calling function, I could understand if it hung on the constructor of the MyObject class but I cannot see how it could hang on the calling function.

                          Chat | Text Messaging | Games | www.uzeddit.com - Coming soon!

                          H Offline
                          H Offline
                          Hesham Yassin
                          wrote on last edited by
                          #18

                          turn MyObject class to a static one, if you cannot, i think i had the same problem with DirectX, where i tried to identify a class which contains a directX identifications. it threw me a bizzar exception. and what i did is putting a breakpoint and run the program pressing F10, at first, it threw me an exception but thenit ran normally. try that. it's so fool but you don't encounter this exception in *.exe file!

                          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