Marshall a pointer to C#? RRS feed

  • Question

  • Hello all, I have limited experience with P/Invoke...just the bare minimum here and there in order to get by. Recently I have the need to interop with a native Dll within my C# project. One of the methods in the Dll returns a pointer to a custom class type. Is there a way use P/Invoke so that I can retrieve this pointer in C# and use the object it's pointing to and, if so, could someone point me in the direction of some example code? I have access to the Dll source code. As always thanks in advance!


    Thursday, March 16, 2017 9:40 PM


  • Hi LKeene,

    Thank you for posting here.

    For your question, you could refer to the MSDN article Calling Native Functions from Managed Code.

    I hope this would be helpful.

    Best Regards,


    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 LKeene Monday, April 3, 2017 8:38 PM
    Friday, March 17, 2017 1:54 AM

All replies