none
how to catch ntdll.dll exception.

    Question

  • VS2015,win7,WPF,native code

    I call one native code, and the wrapper c# code use the Attribute:HandleProcessCorruptedStateException, and SecurityCritical

    but the app catch nothing after encounter the Excpetion Code: 0xC0000374 and crashed.

    Here is the difference: when I run my unit test, the native code run well. but when I run wpf, the exception occurred.

    here is my question, how do I catch this kind of Exception in c#? 


    Wednesday, April 19, 2017 11:26 AM

Answers

  • Hi CrazyOldPotato,

    Thank you for posting here.

    For your question, which way you used to call native code?

    In Managed code, here is two ways.

    Could you provide some demo code for us to repeat your question?

    We are waiting for your update.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CrazyOldPotato Wednesday, April 26, 2017 1:20 AM
    Thursday, April 20, 2017 7:12 AM
    Moderator

All replies

  • Hello,

    Perhaps it's a security problem since running a unit test works and fails otherwise seem this would be a permissions issue that needs to be addressed outside of the app.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, April 19, 2017 12:34 PM
    Moderator
  • thank you for answering my question,

    but what do I need to do for this? I had selected the "Run as administrator"

    Wednesday, April 19, 2017 12:37 PM
  • 0xC0000374 is heap corruption. If memory is corrupted your process is going down and there is nothing you can do about it. You should identify the cause of the corruption and fix it.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, April 19, 2017 2:27 PM
    Moderator
  • Hi CrazyOldPotato,

    Thank you for posting here.

    For your question, which way you used to call native code?

    In Managed code, here is two ways.

    Could you provide some demo code for us to repeat your question?

    We are waiting for your update.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CrazyOldPotato Wednesday, April 26, 2017 1:20 AM
    Thursday, April 20, 2017 7:12 AM
    Moderator
  • Thank you for answering me,

    I found the reason of the exception,

    I built my solution beyond .net framework 4.0,

    and my code call the [DllImport](some unmanaged code),

    and the UI Thread like(WPF,WINFORM,Console) will throw the exception. but the non-UI thread can run the unmanaged code.

    Wednesday, April 26, 2017 1:19 AM