CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2010
    Posts
    5

    Unmanaged exceptions

    Hi Gurus,
    I am porting my application C# which is using several unmanaged c++ DLL's to 64 bit.
    On 32 bits it' works just fine.
    C++: throw
    C#: catch as a SEHException

    On 64 bits(Vista, 7) i have an application crash. I can't catch any of these exceptions...
    Any ideas?

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Unmanaged exceptions

    You can use catch withou exception type, it should catch all exceptions including unmanaged.
    Code:
    try
    {
     ....
    }
    catch
    {
     ...
    }
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    Jun 2010
    Posts
    5

    Re: Unmanaged exceptions

    I tried it without any success.
    The application just crashes whenever i try to throw from unmanaged c++ DLL.
    Fault module name:StackHash_579c... Not mine...

  4. #4
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Unmanaged exceptions

    I don't know if this will work, but try adding a handler to the UnhandledException.
    Something like:
    Code:
    AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventRaised;
    and then make a method to catch it:
    Code:
    private static void UnhandledExceptionEventRaised(object sender, UnhandledExceptionEventArgs e)
    {
    //do stuff here
    }
    But I'm unsure if it will catch your exceptions.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Unmanaged exceptions

    Can you rebuild the C++ dlls for 64-bit?

  6. #6
    Join Date
    Jun 2010
    Posts
    5

    Re: Unmanaged exceptions

    Thanks for trying, but it doesn't help..

  7. #7
    Join Date
    Jun 2010
    Posts
    5

    Re: Unmanaged exceptions

    The DLL's are native 64 bit

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Unmanaged exceptions

    Quote Originally Posted by urisol View Post
    The DLL's are native 64 bit
    Help clear up some confusion, please.

    Are you saying that you've already rebuild the 32-bit dlls for 64-bit?

    If so, how do you know they work as 64-bit? What I would do is write some C++ unit tests to debug the dlls.

    Once you know they work in a 64-bit environment, then you can get them working under .Net.

  9. #9
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Unmanaged exceptions

    What does happen if you check C++ Exceptions in Debug/Exceptions dialog and run the application under debugger. Are you able to determine the exact exception? Maybe it is rewrapped in some way or it could be a security exception because your applications lacks some permission.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  10. #10
    Join Date
    Jun 2010
    Posts
    5

    Re: Unmanaged exceptions

    Yes i have already rebuilt my C++ DLL's for 64 bit and they work just fine.
    Actually the whole application .NET / C++/drivers woks fine except of the unmanaged interrupts issue.
    I see the crash only if i test the unmnaged interrupts flows or just call to c++ foo function from C#(PInvoke)

    c++:
    extern "C" XXINTERFACE_API void foo()throw(...);
    void foo()
    {
    throw blabla;
    }
    I tried to make Blabla to be a native type (int) with no effect..

    I will try to establish 64 bit development environment(mine is 32... cross compiler issue?), to see what happens under debug..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured