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. Exception inside dll

Exception inside dll

Scheduled Pinned Locked Moved C#
databasecsharptutorialquestion
15 Posts 6 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.
  • S sujithkumarsl

    i have written a database application in c#, the application use another c# dll to connect with the database. I am getting some exception inside the c# dll( i have not include exception handling inside the dll), but those exceptions are not being caught from the application. for example

           try
                {
                    DatabaseManager db = new DatabaseManager();
                    db.Execute();
                }
                catch ( Exception ex )
                {
                    // log exception
                }
    

    here the DB.Execute() is crashing inside the dll but not capturing in application.What could be the reason?

    My small attempt...

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    [Message Deleted]

    D 1 Reply Last reply
    0
    • S sujithkumarsl

      i have written a database application in c#, the application use another c# dll to connect with the database. I am getting some exception inside the c# dll( i have not include exception handling inside the dll), but those exceptions are not being caught from the application. for example

             try
                  {
                      DatabaseManager db = new DatabaseManager();
                      db.Execute();
                  }
                  catch ( Exception ex )
                  {
                      // log exception
                  }
      

      here the DB.Execute() is crashing inside the dll but not capturing in application.What could be the reason?

      My small attempt...

      A Offline
      A Offline
      adatapost
      wrote on last edited by
      #3

      You should review of Execute method code.

      A DATAPOST COMPUTER CENTRE (K.V Prajapati)

      S 1 Reply Last reply
      0
      • A adatapost

        You should review of Execute method code.

        A DATAPOST COMPUTER CENTRE (K.V Prajapati)

        S Offline
        S Offline
        sujithkumarsl
        wrote on last edited by
        #4

        Hi here the Execute method is crashing...... Here my problem is that my application is not able to catch that exception.( those exceptions occurs inside the dll)

        My small attempt...

        J 1 Reply Last reply
        0
        • S sujithkumarsl

          Hi here the Execute method is crashing...... Here my problem is that my application is not able to catch that exception.( those exceptions occurs inside the dll)

          My small attempt...

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #5

          Because you've swallowed the exception (and logged it according to your comments) rather than rethrowing it.

          try
          {
          // whatever
          }
          catch(Exception ex)
          {
          // log exception
          throw;
          }

          now the calling application will receive the exception.

          S 1 Reply Last reply
          0
          • J J4amieC

            Because you've swallowed the exception (and logged it according to your comments) rather than rethrowing it.

            try
            {
            // whatever
            }
            catch(Exception ex)
            {
            // log exception
            throw;
            }

            now the calling application will receive the exception.

            S Offline
            S Offline
            sujithkumarsl
            wrote on last edited by
            #6

            There may be some mistake in my question .let me explain it once more.... <pre> try { // This function is inside the DLL Function(); } catch ( Exception ex ) { // Log exception } //Inside the DLL public void Function() { // something which is crashing....... } what i am saying is i am not getting the exception which is occuring inside the dll....

            My small attempt...

            M 1 Reply Last reply
            0
            • S sujithkumarsl

              There may be some mistake in my question .let me explain it once more.... <pre> try { // This function is inside the DLL Function(); } catch ( Exception ex ) { // Log exception } //Inside the DLL public void Function() { // something which is crashing....... } what i am saying is i am not getting the exception which is occuring inside the dll....

              My small attempt...

              M Offline
              M Offline
              Mirko1980
              wrote on last edited by
              #7

              If you are not getting the exception, how do you know Function is crashing?

              S 1 Reply Last reply
              0
              • L Lost User

                [Message Deleted]

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #8

                stancrm wrote:

                from my experience, in that row, the dll create a new thread, and the new thread throw an exception.

                There is no new thread created in that code.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007, 2008

                L 1 Reply Last reply
                0
                • M Mirko1980

                  If you are not getting the exception, how do you know Function is crashing?

                  S Offline
                  S Offline
                  sujithkumarsl
                  wrote on last edited by
                  #9

                  Please come to my question............. ]if i put try catch inside the dll , that will catch the exception

                  My small attempt...

                  L 1 Reply Last reply
                  0
                  • S sujithkumarsl

                    Please come to my question............. ]if i put try catch inside the dll , that will catch the exception

                    My small attempt...

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    [Message Deleted]

                    S 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      stancrm wrote:

                      from my experience, in that row, the dll create a new thread, and the new thread throw an exception.

                      There is no new thread created in that code.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007, 2008

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      [Message Deleted]

                      D 1 Reply Last reply
                      0
                      • L Lost User

                        [Message Deleted]

                        S Offline
                        S Offline
                        sujithkumarsl
                        wrote on last edited by
                        #12

                        For what????? Hi all please understand my question.............. 1. I am calling a method from an application ( example APP) ,which is inside a dll( example DLL) 2. Just assume that that method is crashing( in side DLL) 3. I want to catch the exception in the calling application( APP)( the application from which i called the dll method) ---------------------------------------------------------------------

                        My small attempt...

                        L 1 Reply Last reply
                        0
                        • S sujithkumarsl

                          For what????? Hi all please understand my question.............. 1. I am calling a method from an application ( example APP) ,which is inside a dll( example DLL) 2. Just assume that that method is crashing( in side DLL) 3. I want to catch the exception in the calling application( APP)( the application from which i called the dll method) ---------------------------------------------------------------------

                          My small attempt...

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #13

                          [Message Deleted]

                          S 1 Reply Last reply
                          0
                          • L Lost User

                            [Message Deleted]

                            S Offline
                            S Offline
                            sujithkumarsl
                            wrote on last edited by
                            #14

                            "if you cannot catch the exception from method Execute, that means there is something wrong in the method." please try to understand that i dont want to find the root cause or reason for the exception... i want to catch the exception in the c# application which calls the DLL............. Please imagine that i put some code which generates exception.I dont want to debug and find the reason i just want to catch it on my application...

                            My small attempt...

                            1 Reply Last reply
                            0
                            • L Lost User

                              [Message Deleted]

                              D Offline
                              D Offline
                              Dave Kreskowiak
                              wrote on last edited by
                              #15

                              I don't have to...

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                   2006, 2007, 2008

                              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