none
Cannot pass a GCHandle across AppDomains RRS feed

  • Question

  • UPDATE: I am ready to pay to resolve this issue.. Would like to contact MS .NET development center or a someone who's familiar with .NET on that level.

    In managed code I have some callback that is called from unmanaged Win32 area. It is the wave recording process.

    Prepared PINNED buffers are sent to that unmanaged area and when I try to Free() them with GCHandle.FromIntPtr(hDr.lpData).Free(); I get that message

    Cannot pass a GCHandle across AppDomains

    What technique should I apply? As I understood CLR will place that unmanaged code automatically in different domain, and this happens only in WinForms App, but it works fine as the Console App.

    How to force CLR to keep that callback and the unmanaged code at the same domain?

    Lucky I know why I had GPF each time before, thanks to blocking the optimization with [MethodImpl(MethodImplOptions.NoOptimization)]... now I've got understanding why - because of that domain issue.

    So, please, tell me how to work around that issue? How to avoid the multi domain structure in my case?


    "I = I + 1" .. Isn't it boolshit?



    Wednesday, October 23, 2019 2:41 PM

All replies

  • Hi RobbKirk,

    Thank you for posting here.

    Winform application has wrapped the extant Windows API in managed code which is different from Console application.

    >> How to force CLR to keep that callback

    What does 'callback' mean? Could you provide some related code here? It will help us to analyze and reproduce your question.

    Best Regards,

    Xingyu Zhao


    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.

    Thursday, October 24, 2019 9:34 AM
    Moderator
  • Hi Xingyu ,

    Could you provide me with your email, then I'll send you the project.
    I really need professional help and make this code workable.
    And we ready to send some payment for that.

    Thanks


    "I = I + 1" .. Isn't it boolshit?


    • Edited by RobbKirk Thursday, October 24, 2019 4:09 PM
    Thursday, October 24, 2019 2:57 PM
  • Hi RobbKirk,

    According to our policy, we cannot provide you with our emails.

    oneDrive is a good product for you to share project. 

    Besides, You can divide big project into small problems and ask them in related MSDN forums, and we will do our best to help you.

    Best Regards,

    Xingyu Zhao


    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.

    Tuesday, October 29, 2019 8:47 AM
    Moderator