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. P/Invoke Exceptions

P/Invoke Exceptions

Scheduled Pinned Locked Moved C#
csharpc++comquestion
4 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.
  • H Offline
    H Offline
    HosamAly
    wrote on last edited by
    #1

    Hello, If I call a (pure) C++ function from C# (using P/Invoke), and that function throws an exception, how will it be received in C#? Would it be wrapped into an object of Exception or one of its descendants? Thank you.

    My LinkedIn Profile

    C M 2 Replies Last reply
    0
    • H HosamAly

      Hello, If I call a (pure) C++ function from C# (using P/Invoke), and that function throws an exception, how will it be received in C#? Would it be wrapped into an object of Exception or one of its descendants? Thank you.

      My LinkedIn Profile

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

      I doubt it would be in a form that you'd hope, unless it's a COM exception. But yes, I imagine you'd get an exception that includes any message

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      • H HosamAly

        Hello, If I call a (pure) C++ function from C# (using P/Invoke), and that function throws an exception, how will it be received in C#? Would it be wrapped into an object of Exception or one of its descendants? Thank you.

        My LinkedIn Profile

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        I tried it real quick. On the C# side I get a System.Runtime.InteropServices.SEHException Message == "External component has thrown an exception."

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        H 1 Reply Last reply
        0
        • M Mark Salsbery

          I tried it real quick. On the C# side I get a System.Runtime.InteropServices.SEHException Message == "External component has thrown an exception."

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          H Offline
          H Offline
          HosamAly
          wrote on last edited by
          #4

          Thanks a lot!

          My LinkedIn Profile

          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